You are here

function template_preprocess_slick_slide in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 templates/slick.theme.inc \template_preprocess_slick_slide()
  2. 7.3 templates/slick.theme.inc \template_preprocess_slick_slide()

Prepares variables for slick-slide.html.twig templates.

File

templates/slick.theme.inc, line 159
Hooks and preprocess functions for the Slick module.

Code

function template_preprocess_slick_slide(&$variables) {
  _slick_preprocess_slick_item($variables);

  // All slide types -- main, thumbnail, grid, overlay -- may have captions.
  foreach ([
    'alt',
    'data',
    'link',
    'overlay',
    'title',
  ] as $key) {
    $variables['item']['caption'][$key] = isset($variables['item']['caption'][$key]) ? $variables['item']['caption'][$key] : [];
  }
  $item =& $variables['item'];
  $settings =& $variables['settings'];
  $variables['caption_attributes'] = new Attribute();

  // split: Split image from captions if we do have captions, and main image.
  // fullwidth: If full skins, add wrappers to hold caption and overlay.
  // detroy: Remove .slide__content if it is an enforced unslick grid.
  // wrapper: Don't add divities for a single item to have clean markups.
  $item['slide'] = isset($item['slide']) ? $item['slide'] : [];
  $item['caption'] = array_filter($item['caption']);
  $settings['split'] = !empty($item) && (!empty($settings['caption']) || !empty($settings['title']));
  $settings['data'] = !empty($item['caption']['alt']) || !empty($item['caption']['title']) || !empty($item['caption']['data']);
  $settings['fullwidth'] = !empty($settings['skin']) && strpos($settings['skin'], 'full') !== FALSE;
  $settings['grid'] = empty($settings['grid']) ? FALSE : $settings['grid'];
  $settings['detroy'] = $settings['current_item'] == 'main' && !empty($settings['grid']) && !empty($settings['unslick']);
  $settings['wrapper'] = $settings['count'] > 1 && $settings['current_item'] != 'grid';
}