function lazy_preprocess_responsive_image in Lazy-load 8.3
Implements template_preprocess_responsive_image().
File
- ./
lazy.module, line 252 - Module file for Lazy-load.
Code
function lazy_preprocess_responsive_image(&$variables) {
if (array_key_exists('data-lazy', $variables['attributes'])) {
// The `data-lazy` attribute will be removed in `lazy_preprocess_image()`.
$lazy_service = \Drupal::service('lazy');
if ($lazy_service
->isEnabled()) {
$config = $lazy_service
->getSettings();
foreach ($variables['sources'] as $source) {
if (isset($source['srcset'])) {
$source[$config['lazysizes']['srcsetAttr']] = $source['srcset'];
unset($source['srcset']);
}
if (isset($source['sizes'])) {
$source[$config['lazysizes']['sizesAttr']] = $source['sizes'];
unset($source['sizes']);
}
}
}
}
}