protected function MediaImage::getItem in Lightning Media 8
Same name and namespace in other branches
- 8.4 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getItem()
- 8.2 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getItem()
- 8.3 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getItem()
Returns the image field item to use for the embedded entity.
Return value
\Drupal\image\Plugin\Field\FieldType\ImageItem The image field item.
1 call to MediaImage::getItem()
- MediaImage::getAttributeValues in src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImage.php - Gets the values for all attributes.
File
- src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImage.php, line 99
Class
- MediaImage
- Renders a media item's image via the image formatter.
Namespace
Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplayCode
protected function getItem() {
/** @var \Drupal\media\MediaInterface $entity */
$entity = $this
->getEntityFromContext();
$item = MediaHelper::getSourceField($entity)
->first();
return $item instanceof ImageItem ? $item : $entity
->get('thumbnail')
->first();
}