function ViewsConfigUpdater::processImageLazyLoadFieldHandler

Processes image type fields.

Parameters

array $handler: A display handler.

string $handler_type: The handler type.

\Drupal\views\ViewEntityInterface $view: The View being updated.

Return value

bool Whether the handler was updated.

2 calls to ViewsConfigUpdater::processImageLazyLoadFieldHandler()
ViewsConfigUpdater::needsImageLazyLoadFieldUpdate in core/modules/views/src/ViewsConfigUpdater.php
Add lazy load options to all image type field configurations.
ViewsConfigUpdater::updateAll in core/modules/views/src/ViewsConfigUpdater.php
Performs all required updates.

File

core/modules/views/src/ViewsConfigUpdater.php, line 529

Class

ViewsConfigUpdater
Provides a BC layer for modules providing old configurations.

Namespace

Drupal\views

Code

protected function processImageLazyLoadFieldHandler(array &$handler, string $handler_type, ViewEntityInterface $view) {
    $changed = FALSE;
    // Add any missing settings for lazy loading.
    if ($handler_type === 'field' && isset($handler['plugin_id'], $handler['type']) && $handler['plugin_id'] === 'field' && $handler['type'] === 'image' && !isset($handler['settings']['image_loading'])) {
        $handler['settings']['image_loading'] = [
            'attribute' => 'lazy',
        ];
        $changed = TRUE;
    }
    return $changed;
}

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