You are here

public function SlickImageFormatter::buildElement in Slick Carousel 7.3

Build individual item if so configured such as for file entity goodness.

Overrides BlazyFormatterBase::buildElement

File

src/Plugin/Field/FieldFormatter/SlickImageFormatter.php, line 22

Class

SlickImageFormatter
Plugin implementation of the 'Slick Image' formatter.

Namespace

Drupal\slick\Plugin\Field\FieldFormatter

Code

public function buildElement(array &$element, $entity, $delta = 0) {
  $settings = $element['settings'];
  $item_id = $settings['item_id'];

  // Image with responsive image, lazyLoad, and lightbox supports.
  $element[$item_id] = $this
    ->formatter()
    ->getBlazy($element);

  // Build caption if so configured, supports file entity/ media via $file.
  if (!empty($settings['caption'])) {
    foreach ($settings['caption'] as $caption) {
      $element['caption'][$caption] = $this
        ->getCaption($entity, $caption, $element['settings']);
    }
  }
}