You are here

public function GridStackFileFormatter::buildElement in GridStack 8.2

File

src/Plugin/Field/FieldFormatter/GridStackFileFormatter.php, line 26

Class

GridStackFileFormatter
Plugin implementation of the 'GridStack' formatter to get ME within images.

Namespace

Drupal\gridstack\Plugin\Field\FieldFormatter

Code

public function buildElement(array &$build, $entity) {
  $settings = $build['settings'];
  $data = [];

  /** @var Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $item */

  // EntityReferenceItem provides $item->entity Drupal\file\Entity\File.
  if (empty($build['item'])) {
    if ($data = $this->blazyOembed
      ->getImageItem($entity)) {
      $build['item'] = $data['item'];
      $build['settings'] = array_merge($settings, $data['settings']);
    }
  }
  $this->blazyOembed
    ->getMediaItem($build, $entity);
}