5 * Testing various Blazy hooks, etc.
9 * Implements hook_theme().
11 function blazy_test_theme() {
12 return ['blazy_test' => ['render element' => 'element']];
16 * Prepares variables for blazy-test.html.twig templates.
18 function template_preprocess_blazy_test(&$variables) {
19 $element = $variables['element'];
21 $variables['content'] = $element['#children'];
22 $variables['settings'] = isset($element['#settings']) ? $element['#settings'] : [];
26 * Implements hook_blazy_attach_alter().
28 function blazy_test_blazy_attach_alter(array &$load, array $settings = []) {
29 if (!empty($settings['blazy_test'])) {
30 $load['library'][] = 'foo/fake_library';
32 $manager = \Drupal::service('blazy.manager');
33 $template = ['#theme' => 'blazy_test'];
34 $load['drupalSettings']['blazy_test'] = [
35 'options' => ['slideshow' => TRUE],
36 'container' => $manager->getRenderer()->renderPlain($template),
42 * Implements hook_blazy_attach_alter().
44 function blazy_test_blazy_lightboxes_alter(array &$lightboxes) {
45 $lightboxes[] = 'blazy_test';
49 * Implements hook_blazy_attach_alter().
51 function blazy_test_blazy_alter(array &$image, array $settings = []) {
52 if (!empty($settings['media_switch']) && $settings['media_switch'] == 'blazy_test') {
53 $image['#pre_render'][] = 'blazy_test_pre_render';
58 * #pre_render callback: Sets blazy_test related URL attributes.
60 function blazy_test_pre_render($image) {
61 $settings = isset($image['#settings']) ? $image['#settings'] : [];
63 // Video's HREF points to external site, adds URL to local image.
64 if (!empty($settings['box_url']) && !empty($settings['embed_url'])) {
65 $image['#url_attributes']['data-box-url'] = $settings['box_url'];
72 * Implements hook_hook_info().
74 function blazy_test_hook_info() {
75 $hooks['blazy_test_skins_info'] = ['group' => 'blazy_test'];
79 if (!function_exists('token_theme')) {
84 function token_theme() {
85 // Empty block to satisfy coder.
90 if (!function_exists('video_embed_media_media_bundle_insert')) {
95 function video_embed_media_media_bundle_insert() {
96 // Empty block to satisfy coder.