function background_image_preprocess_html in Background Image 2.x
Same name and namespace in other branches
- 8 background_image.module \background_image_preprocess_html()
- 2.0.x background_image.module \background_image_preprocess_html()
Implements hook_preprocess_HOOK().
File
- ./
background_image.module, line 93 - Background Image module's procedural hooks and functions.
Code
function background_image_preprocess_html(&$variables) {
$manager = BackgroundImageManager::service();
if ($background_image = $manager
->getBackgroundImage()) {
$base_class = $manager
->getBaseClass();
if ($background_image
->getSetting('dark')) {
$variables['attributes']['class'][] = "{$base_class}-dark";
}
if ($background_image
->getSetting('full_viewport')) {
$variables['attributes']['class'][] = "{$base_class}-full-viewport";
}
}
$variables['#cache']['context'][] = 'background_image.settings.dark';
$variables['#cache']['context'][] = 'background_image.settings.full_viewport';
}