function ImageConfigUpdater::processImageLazyLoad

Re-order mappings by breakpoint ID and descending numeric multiplier order.

Parameters

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

Return value

bool Whether the display was updated.

File

core/modules/image/src/ImageConfigUpdater.php, line 26

Class

ImageConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\image

Code

public function processImageLazyLoad(EntityViewDisplayInterface $view_display) : bool {
    $changed = FALSE;
    foreach ($view_display->getComponents() as $field => $component) {
        if (isset($component['type']) && $component['type'] === 'image' && !array_key_exists('image_loading', $component['settings'])) {
            $component['settings']['image_loading']['attribute'] = 'lazy';
            $view_display->setComponent($field, $component);
            $changed = TRUE;
        }
    }
    return $changed;
}

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