You are here

public function SlickFileFormatter::buildElements in Slick Carousel 7.3

Build the slick carousel elements.

Overrides SlickFormatterBase::buildElements

File

src/Plugin/Field/FieldFormatter/SlickFileFormatter.php, line 60

Class

SlickFileFormatter
Plugin implementation of the 'Slick File' formatter for Media integration.

Namespace

Drupal\slick\Plugin\Field\FieldFormatter

Code

public function buildElements(array &$build, $items) {
  $settings =& $build['settings'];
  $item_id = $settings['item_id'];

  // Render items as is when using vanilla.
  if (!empty($settings['vanilla'])) {
    foreach ($items as $delta => $item) {
      $settings['delta'] = $delta;
      $settings['type'] = isset($item->type) ? $item->type : 'image';
      $element = [
        'item' => $item,
        'settings' => $settings,
      ];
      $element[$item_id] = $this
        ->blazyEntity()
        ->entityView($this->targetType, $item, $settings);

      // Build individual slick item.
      $build['items'][$delta] = $element;
    }
    return;
  }

  // Otherwise process elements based on advanced features.
  parent::buildElements($build, $items);
}