function lazy_page_attachments in Lazy-load 8.2
Same name and namespace in other branches
- 8.3 lazy.module \lazy_page_attachments()
- 8 lazy.module \lazy_page_attachments()
Implements hook_page_attachments().
File
- ./
lazy.module, line 95 - Module file for Lazy-load.
Code
function lazy_page_attachments(array &$attachments) {
$config = lazy_is_enabled();
if ($config) {
$options = [
'errorClass' => $config['errorClass'],
'loadInvisible' => (bool) $config['loadInvisible'],
'offset' => (int) $config['offset'],
'saveViewportOffsetDelay' => (int) $config['saveViewportOffsetDelay'],
'selector' => '.' . $config['selector'],
'skipClass' => $config['skipClass'],
'src' => $config['src'],
'successClass' => $config['successClass'],
'validateDelay' => $config['validateDelay'],
'placeholderSrc' => $config['placeholderSrc'],
];
$attachments['#attached']['library'][] = 'lazy/lazy';
$attachments['#attached']['drupalSettings']['lazy'] = $options;
}
}