You are here

function template_preprocess_fotorama_gallery_field in Fotorama Gallery 8.2

Same name and namespace in other branches
  1. 8 fotorama_gallery.module \template_preprocess_fotorama_gallery_field()

Prepares variables for fotorama gallery field templates.

Default template: fotorama-gallery-field.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #children, #attributes.

File

./fotorama_gallery.module, line 29
Add new formatter display to image field.

Code

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'];
}