You are here

function flickity_pre_render_element in Flickity Carousel 8.2

Same name and namespace in other branches
  1. 8 theme/flickity.theme.inc \flickity_pre_render_element()

Pre render Flickity output.

1 string reference to 'flickity_pre_render_element'
theme_flickity in theme/flickity.theme.inc
Theme declaration for Flickity.

File

theme/flickity.theme.inc, line 51
flickity.theme.inc

Code

function flickity_pre_render_element($element) {
  $items = array();
  foreach ($element['#output']['items'] as $key => $item) {
    $items[] = array(
      '#theme' => 'flickity_item',
      '#item' => $item['row'],
      '#attributes' => array(
        'class' => array(
          'gallery-cell',
          'item-' . $key,
        ),
      ),
    );
  }

  // Build wrapper with Flickity items.
  $build = flickity_build($element['#output']['settings'], $items);

  // Provide pre render alter.
  \Drupal::moduleHandler()
    ->alter('pre_render', $build);

  // Render the complete Flickity element.
  $element['#children'] = drupal_render($build);
  return $element;
}