function blazy_photoswipe_blazy_attach_alter in Blazy PhotoSwipe 8
Same name and namespace in other branches
- 7 blazy_photoswipe.module \blazy_photoswipe_blazy_attach_alter()
Implements hook_blazy_attach_alter().
File
- ./
blazy_photoswipe.module, line 25 - Provides a simple Blazy PhotoSwipe integration.
Code
function blazy_photoswipe_blazy_attach_alter(array &$load, $attach = []) {
if (!empty($attach['photoswipe'])) {
$config = blazy()
->configLoad();
$five = !empty($config['extras']['photoswipe']) && $config['extras']['photoswipe'] == 5;
$load['library'][] = $five ? 'blazy_photoswipe/load5' : 'blazy_photoswipe/load';
// Allow other modules to alter / extend the options to pass to photoswipe.
$options = blazy()
->configLoad('options', 'photoswipe.settings');
blazy()
->getModuleHandler()
->alter('blazy_photoswipe_js_options', $options);
$load['drupalSettings']['photoswipe']['options'] = $options;
if (!$five) {
$template = [
'#theme' => 'photoswipe_container',
];
$load['drupalSettings']['photoswipe']['container'] = blazy()
->getRenderer()
->renderPlain($template);
}
}
}