You are here

imagelightbox.module in ImageLightbox 8

Same filename and directory in other branches
  1. 2.x imagelightbox.module
  2. 2.0.x imagelightbox.module

Primary module hooks for ImageLightBox module.

File

imagelightbox.module
View source
<?php

/**
 * @file
 * Primary module hooks for ImageLightBox module.
 */
use Drupal\Core\Template\Attribute;
use Drupal\Core\Template\Image;

/**
 * Implements hook_theme().
 */
function imagelightbox_theme() {
  return [
    'imagelightbox_formatter' => [
      'variables' => [
        'item' => NULL,
        'item_attributes' => NULL,
        'link_attributes' => NULL,
        'url' => NULL,
        'image_style' => NULL,
      ],
    ],
  ];
}

/**
 * Prepares variables for imagelightbox formatter templates.
 *
 * Default template: imagelightbox-formatter.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - item: An ImageItem object.
 *   - item_attributes: An optional associative array of html attributes to be
 *     placed in the img tag.
 *   - image_style: An optional image style.
 *   - url: An optional \Drupal\Core\Url object.
 */
function template_preprocess_imagelightbox_formatter(&$variables) {
  module_load_include('inc', 'image', 'image.field');
  template_preprocess_image_formatter($variables);
  $variables['link_attributes'] = new Attribute($variables['link_attributes']);
  $variables['#attached']['library'][] = 'imagelightbox/formatter';
}

Functions

Namesort descending Description
imagelightbox_theme Implements hook_theme().
template_preprocess_imagelightbox_formatter Prepares variables for imagelightbox formatter templates.