function template_preprocess_image_anchor

template_preprocess_image_anchor(&$variables)

Prepares variables for image anchor templates.

Default template: image-anchor.html.twig.

Parameters

array $variables: An associative array containing:

  • element: An associative array containing the image.

File

core/modules/image/image.admin.inc, line 109
Administration pages for image settings.

Code

function template_preprocess_image_anchor(&$variables) {
  $element = $variables['element'];

  $rows = array();
  $row = array();
  foreach (Element::children($element) as $n => $key) {
    $element[$key]['#attributes']['title'] = $element[$key]['#title'];
    unset($element[$key]['#title']);
    $row[] = array(
      'data' => $element[$key],
    );
    if ($n % 3 == 3 - 1) {
      $rows[] = $row;
      $row = array();
    }
  }

  $variables['table'] = array(
    '#type' => 'table',
    '#header' => array(),
    '#rows' => $rows,
    '#attributes' => array(
      'class' => array('image-anchor'),
    ),
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!image!image.admin.inc/function/template_preprocess_image_anchor/8.1.x