You are here

function hook_blazy_attach_alter in Blazy 8.2

Same name and namespace in other branches
  1. 8 blazy.api.php \hook_blazy_attach_alter()
  2. 7 blazy.api.php \hook_blazy_attach_alter()

Alters Blazy attachments to add own library, drupalSettings, and JS template.

Parameters

array $load: The array of loaded library being modified.

array $settings: The available array of settings.

Related topics

1 function implements hook_blazy_attach_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

blazy_test_blazy_attach_alter in tests/modules/blazy_test/blazy_test.module
Implements hook_blazy_attach_alter().
1 invocation of hook_blazy_attach_alter()
BlazyManagerBase::attach in src/BlazyManagerBase.php
Returns array of needed assets suitable for #attached property.

File

./blazy.api.php, line 138
Hooks and API provided by the Blazy module.

Code

function hook_blazy_attach_alter(array &$load, array $settings = []) {
  if (!empty($settings['photoswipe'])) {
    $load['library'][] = 'my_module/load';
    $template = [
      '#theme' => 'photoswipe_container',
    ];
    $load['drupalSettings']['photoswipe'] = [
      'options' => blazy()
        ->configLoad('options', 'photoswipe.settings'),
      'container' => blazy()
        ->getRenderer()
        ->renderPlain($template),
    ];
  }
}