public function BlazyFileFormatter::buildElement in Blazy 8.2
Same name and namespace in other branches
- 7 src/Plugin/Field/FieldFormatter/BlazyFileFormatter.php \Drupal\blazy\Plugin\Field\FieldFormatter\BlazyFileFormatter::buildElement()
Build individual item if so configured such as for file ER goodness.
Overrides BlazyFileFormatterBase::buildElement
File
- src/
Plugin/ Field/ FieldFormatter/ BlazyFileFormatter.php, line 30
Class
- BlazyFileFormatter
- Plugin implementation of the 'Blazy File' to get VEF/VEM within images/files.
Namespace
Drupal\blazy\Plugin\Field\FieldFormatterCode
public function buildElement(array &$build, $entity) {
$settings = $build['settings'];
/** @var Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $item */
// EntityReferenceItem provides $item->entity Drupal\file\Entity\File.
if ($item = $this->blazyOembed
->getImageItem($entity)) {
$build['item'] = $item['item'];
$build['settings'] = array_merge($settings, $item['settings']);
}
$this->blazyOembed
->getMediaItem($build, $entity);
}