imagelightbox.module in ImageLightbox 8
Same filename and directory in other branches
Primary module hooks for ImageLightBox module.
File
imagelightbox.moduleView 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
Name | Description |
---|---|
imagelightbox_theme | Implements hook_theme(). |
template_preprocess_imagelightbox_formatter | Prepares variables for imagelightbox formatter templates. |