public function SlickFormatterBase::buildElements in Slick Carousel 7.3
Build the slick carousel elements.
1 call to SlickFormatterBase::buildElements()
- SlickFileFormatter::buildElements in src/
Plugin/ Field/ FieldFormatter/ SlickFileFormatter.php - Build the slick carousel elements.
1 method overrides SlickFormatterBase::buildElements()
- SlickFileFormatter::buildElements in src/
Plugin/ Field/ FieldFormatter/ SlickFileFormatter.php - Build the slick carousel elements.
File
- src/
Plugin/ Field/ FieldFormatter/ SlickFormatterBase.php, line 37
Class
- SlickFormatterBase
- Base class for slick image and file entity (Media) formatters.
Namespace
Drupal\slick\Plugin\Field\FieldFormatterCode
public function buildElements(array &$build, $items) {
$settings = $build['settings'];
$item_id = $settings['item_id'];
foreach ($items as $delta => $item) {
$settings['delta'] = $delta;
$settings['type'] = isset($item->type) ? $item->type : 'image';
$settings['uri'] = $item->uri;
$element = [
'item' => $item,
'settings' => $settings,
'content' => [],
];
// Provide advanced functionality to build fieldable elements.
$this
->buildElement($element, $item, $delta);
// Build individual slick item.
$build['items'][$delta] = $element;
// Build individual slick thumbnail.
if (!empty($settings['nav'])) {
$thumb = [
'settings' => $element['settings'],
];
// Thumbnail usages: asNavFor pagers, dot, arrows, photobox thumbnails.
$thumb[$item_id] = empty($settings['thumbnail_style']) ? [] : $this
->formatter()
->getThumbnail($element['settings'], $element['item']);
$thumb['caption'] = empty($settings['thumbnail_caption']) ? [] : array_filter($this
->getCaption($item, $settings['thumbnail_caption'], $settings));
$build['thumb']['items'][$delta] = $thumb;
}
}
}