orderMultipliersNumerically example


}

/** * Re-order mappings by breakpoint ID and descending numeric multiplier order. */
function responsive_image_post_update_order_multiplier_numerically(array &$sandbox = NULL): void {
  /** @var \Drupal\responsive_image\ResponsiveImageConfigUpdater $responsive_image_config_updater */
  $responsive_image_config_updater = \Drupal::classResolver(ResponsiveImageConfigUpdater::class);
  $responsive_image_config_updater->setDeprecationsEnabled(FALSE);
  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'responsive_image_style', function DResponsiveImageStyleInterface $responsive_image_style) use ($responsive_image_config_updater): bool {
    return $responsive_image_config_updater->orderMultipliersNumerically($responsive_image_style);
  });
}

/** * Add the image loading settings to responsive image field formatter instances. */
function responsive_image_post_update_image_loading_attribute(array &$sandbox = NULL): void {
  $responsive_image_config_updater = \Drupal::classResolver(ResponsiveImageConfigUpdater::class);
  $responsive_image_config_updater->setDeprecationsEnabled(FALSE);
  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'entity_view_display', function DEntityViewDisplayInterface $view_display) use ($responsive_image_config_updater): bool {
    return $responsive_image_config_updater->processResponsiveImageField($view_display);
  });

  public function __construct(array $values$entity_type_id = 'responsive_image_style') {
    parent::__construct($values$entity_type_id);
  }

  /** * {@inheritdoc} */
  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    $config_updater = \Drupal::classResolver(ResponsiveImageConfigUpdater::class);
    $config_updater->orderMultipliersNumerically($this);
  }

  /** * {@inheritdoc} */
  public function addImageStyleMapping($breakpoint_id$multiplier, array $image_style_mapping) {
    // If there is an existing mapping, overwrite it.     foreach ($this->image_style_mappings as &$mapping) {
      if ($mapping['breakpoint_id'] === $breakpoint_id && $mapping['multiplier'] === $multiplier) {
        $mapping = $image_style_mapping + [
          'breakpoint_id' => $breakpoint_id,
          
Home | Imprint | This part of the site doesn't use cookies.