function lazy_preprocess_image in Lazy-load 8.2
Same name and namespace in other branches
- 8.3 lazy.module \lazy_preprocess_image()
- 8 lazy.module \lazy_preprocess_image()
Implements template_preprocess_image().
File
- ./
lazy.module, line 82 - Module file for Lazy-load.
Code
function lazy_preprocess_image(&$variables) {
if (array_key_exists('data-lazy-load-fields', $variables['attributes'])) {
unset($variables['attributes']['data-lazy-load-fields']);
$config = \Drupal::config('lazy.settings')
->get();
$variables['attributes'][$config['src']] = $variables['attributes']['src'];
$variables['attributes']['src'] = $config['placeholderSrc'];
$variables['attributes']['class'][] = $config['selector'];
}
}