You are here

fotorama_gallery.module in Fotorama Gallery 8.2

Same filename and directory in other branches
  1. 8 fotorama_gallery.module

Add new formatter display to image field.

File

fotorama_gallery.module
View source
<?php

/**
 * @file
 * Add new formatter display to image field.
 */

/**
 * Implements hook_theme().
 */
function fotorama_gallery_theme() {
  return [
    'fotorama_gallery_field' => [
      'render element' => 'element',
    ],
  ];
}

/**
 * Prepares variables for fotorama gallery field templates.
 *
 * Default template: fotorama-gallery-field.html.twig.
 *
 * @param array $variables
 *   An associative array containing:
 *   - element: An associative array containing the properties of the element.
 *     Properties used: #children, #attributes.
 */
function template_preprocess_fotorama_gallery_field(array &$variables) {
  $element = $variables['element'];
  $variables['label_hidden'] = $element['#label_display'] == 'hidden';

  // Always set the field label - allow themes to decide whether to display it.
  // In addition the label should be rendered but hidden to support screen
  // readers.
  $variables['label'] = $element['#title'];
  $variables['multiple'] = $element['#is_multiple'];
  $variables['items'] = [];
  $delta = 0;
  while (!empty($element[$delta])) {
    $variables['items'][$delta]['content'] = $element[$delta];
    $delta++;
  }
  $variables['attributes'] = $variables['element']['attributes'];
}

Functions

Namesort descending Description
fotorama_gallery_theme Implements hook_theme().
template_preprocess_fotorama_gallery_field Prepares variables for fotorama gallery field templates.