class ImageConfigUpdater

Provides a BC layer for modules providing old configurations.

@internal This class is only meant to fix outdated image configuration and its methods should not be invoked directly. It will be removed once all the deprecated methods have been removed.

Hierarchy

Expanded class hierarchy of ImageConfigUpdater

2 files declare their use of ImageConfigUpdater
image.module in core/modules/image/image.module
Exposes global functionality for creating image styles.
image.post_update.php in core/modules/image/image.post_update.php
Post-update functions for Image.

File

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

Namespace

Drupal\image
View source
final class ImageConfigUpdater {
    
    /**
     * Re-order mappings by breakpoint ID and descending numeric multiplier order.
     *
     * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display
     *   The view display.
     *
     * @return bool
     *   Whether the display was updated.
     */
    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;
    }

}

Members

Title Sort descending Modifiers Object type Summary
ImageConfigUpdater::processImageLazyLoad public function Re-order mappings by breakpoint ID and descending numeric multiplier order.

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