You are here

function hook_blazy_attach_alter in Blazy 8

Same name and namespace in other branches
  1. 8.2 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

2 functions implement 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_blazy_attach_alter in ./blazy.module
Implements hook_blazy_attach_alter().
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';
    $manager = \Drupal::service('blazy.manager');
    $template = [
      '#theme' => 'photoswipe_container',
    ];
    $load['drupalSettings']['photoswipe'] = [
      'options' => $manager
        ->configLoad('options', 'photoswipe.settings'),
      'container' => $manager
        ->getRenderer()
        ->renderPlain($template),
    ];
  }
}