You are here

protected function BlazyMediaFormatter::getEntitiesToView in Blazy 8

A clone of Drupal\image\Plugin\Field\FieldFormatter\ImageFormatterBase so to have one base class to extend for both image and file ER formatters.

Overrides BlazyFileFormatterBase::getEntitiesToView

File

src/Plugin/Field/FieldFormatter/BlazyMediaFormatter.php, line 27

Class

BlazyMediaFormatter
Plugin for blazy media formatter.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

protected function getEntitiesToView(EntityReferenceFieldItemListInterface $items, $langcode) {
  $media = parent::getEntitiesToView($items, $langcode);
  $entities = [];
  foreach ($media as $media_item) {
    $entity = $media_item->thumbnail->entity;
    $entity->_referringItem = $media_item->thumbnail;
    $entities[] = $entity;
  }
  return $entities;
}