['render element' => 'element']]; } /** * Prepares variables for blazy-test.html.twig templates. */ function template_preprocess_blazy_test(&$variables) { $element = $variables['element']; $variables['content'] = $element['#children']; $variables['settings'] = isset($element['#settings']) ? $element['#settings'] : []; } /** * Implements hook_blazy_attach_alter(). */ function blazy_test_blazy_attach_alter(array &$load, array $settings = []) { if (!empty($settings['blazy_test'])) { $load['library'][] = 'foo/fake_library'; $manager = \Drupal::service('blazy.manager'); $template = ['#theme' => 'blazy_test']; $load['drupalSettings']['blazy_test'] = [ 'options' => ['slideshow' => TRUE], 'container' => $manager->getRenderer()->renderPlain($template), ]; } } /** * Implements hook_blazy_attach_alter(). */ function blazy_test_blazy_lightboxes_alter(array &$lightboxes) { $lightboxes[] = 'blazy_test'; } /** * Implements hook_blazy_attach_alter(). */ function blazy_test_blazy_alter(array &$image, array $settings = []) { if (!empty($settings['media_switch']) && $settings['media_switch'] == 'blazy_test') { $image['#pre_render'][] = 'blazy_test_pre_render'; } } /** * #pre_render callback: Sets blazy_test related URL attributes. */ function blazy_test_pre_render($image) { $settings = isset($image['#settings']) ? $image['#settings'] : []; // Video's HREF points to external site, adds URL to local image. if (!empty($settings['box_url']) && !empty($settings['embed_url'])) { $image['#url_attributes']['data-box-url'] = $settings['box_url']; } return $image; } /** * Implements hook_hook_info(). */ function blazy_test_hook_info() { $hooks['blazy_test_skins_info'] = ['group' => 'blazy_test']; return $hooks; } if (!function_exists('token_theme')) { /** * Dummy function. */ function token_theme() { // Empty block to satisfy coder. } } if (!function_exists('video_embed_media_media_bundle_insert')) { /** * Dummy function. */ function video_embed_media_media_bundle_insert() { // Empty block to satisfy coder. } }