You are here

public function SlickEntityReferenceFormatterBase::buildElementThumbnail in Slick Carousel 8.2

File

src/Plugin/Field/FieldFormatter/SlickEntityReferenceFormatterBase.php, line 47

Class

SlickEntityReferenceFormatterBase
Base class for slick entity reference formatters with field details.

Namespace

Drupal\slick\Plugin\Field\FieldFormatter

Code

public function buildElementThumbnail(array &$build, $element, $entity, $delta) {

  // @todo move it to Slick as too specific for Slick which has thumbnail.
  // The settings in $element has updated metadata extracted from media.
  $settings = $element['settings'];
  $item_id = $settings['item_id'];
  if (!empty($settings['nav'])) {

    // Thumbnail usages: asNavFor pagers, dot, arrows, photobox thumbnails.
    $element[$item_id] = empty($settings['thumbnail_style']) ? [] : $this
      ->formatter()
      ->getThumbnail($settings, $element['item']);
    $element['caption'] = empty($settings['thumbnail_caption']) ? [] : $this
      ->blazyEntity()
      ->getFieldRenderable($entity, $settings['thumbnail_caption'], $settings['view_mode']);
    $build['thumb']['items'][$delta] = $element;
  }
}