SlickImageFormatter.php in Slick Carousel 7.3
File
src/Plugin/Field/FieldFormatter/SlickImageFormatter.php
View source
<?php
namespace Drupal\slick\Plugin\Field\FieldFormatter;
class SlickImageFormatter extends SlickFormatterBase {
use SlickFormatterTrait;
protected function getCaption($item, $caption, $settings) {
return empty($item->{$caption}) ? [] : [
'#markup' => filter_xss_admin($item->{$caption}),
];
}
public function buildElement(array &$element, $entity, $delta = 0) {
$settings = $element['settings'];
$item_id = $settings['item_id'];
$element[$item_id] = $this
->formatter()
->getBlazy($element);
if (!empty($settings['caption'])) {
foreach ($settings['caption'] as $caption) {
$element['caption'][$caption] = $this
->getCaption($entity, $caption, $element['settings']);
}
}
}
}