private function BlazyManager::buildImage in Blazy 8.2
Same name and namespace in other branches
- 7 src/BlazyManager.php \Drupal\blazy\BlazyManager::buildImage()
Build out image, or anything related, including cache, CSS background, etc.
1 call to BlazyManager::buildImage()
- BlazyManager::buildMedia in src/
BlazyManager.php - Build out (Responsive) image.
File
- src/
BlazyManager.php, line 307
Class
- BlazyManager
- Implements a public facing blazy manager.
Namespace
Drupal\blazyCode
private function buildImage(array &$element, array &$attributes, array &$item_attributes, array &$settings) {
if (!empty($settings['lazy']) && !empty($settings['background'])) {
// Attach data attributes to either IMG tag, or DIV container.
$settings['urls'][$settings['width']] = $this
->backgroundImage($settings);
$settings['image_url'] = empty($settings['is_preview']) ? $settings['placeholder'] : $settings['image_url'];
Blazy::lazyAttributes($attributes, $settings);
}
if (empty($settings['_no_cache'])) {
$file_tags = isset($settings['file_tags']) ? $settings['file_tags'] : [];
$settings['cache_tags'] = empty($settings['cache_tags']) ? $file_tags : Cache::mergeTags($settings['cache_tags'], $file_tags);
$element['#cache']['max-age'] = -1;
foreach ([
'contexts',
'keys',
'tags',
] as $key) {
if (!empty($settings['cache_' . $key])) {
$element['#cache'][$key] = $settings['cache_' . $key];
}
}
}
}