function ResponsiveImageConfigUpdater::processResponsiveImageField

Same name in other branches
  1. 10 core/modules/responsive_image/src/ResponsiveImageConfigUpdater.php \Drupal\responsive_image\ResponsiveImageConfigUpdater::processResponsiveImageField()

Processes responsive image type fields.

Parameters

\Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display: The view display.

Return value

bool Whether the display was updated.

File

core/modules/responsive_image/src/ResponsiveImageConfigUpdater.php, line 82

Class

ResponsiveImageConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\responsive_image

Code

public function processResponsiveImageField(EntityViewDisplayInterface $view_display) : bool {
    $changed = FALSE;
    foreach ($view_display->getComponents() as $field => $component) {
        if (isset($component['type']) && $component['type'] === 'responsive_image' && !array_key_exists('image_loading', $component['settings'])) {
            $component['settings']['image_loading']['attribute'] = 'eager';
            $view_display->setComponent($field, $component);
            $changed = TRUE;
        }
    }
    $deprecations_triggered =& $this->triggeredDeprecations['3192234'][$view_display->id()];
    if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
        $deprecations_triggered = TRUE;
        @trigger_error(sprintf('The responsive image loading attribute update for "%s" is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Configuration should be updated. See https://www.drupal.org/node/3279032', $view_display->id()), E_USER_DEPRECATED);
    }
    return $changed;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.