You are here

protected function MediaImage::getItem in Varbase Media 8.5

Same name and namespace in other branches
  1. 8.7 modules/entity_browser_generic_embed/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\entity_browser_generic_embed\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getItem()
  2. 8.6 modules/entity_browser_generic_embed/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\entity_browser_generic_embed\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getItem()
  3. 9.0.x modules/entity_browser_generic_embed/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\entity_browser_generic_embed\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 modules/entity_browser_generic_embed/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php
Gets the values for all attributes.

File

modules/entity_browser_generic_embed/src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php, line 99

Class

MediaImage
Renders a media item's image via the image formatter.

Namespace

Drupal\entity_browser_generic_embed\Plugin\entity_embed\EntityEmbedDisplay

Code

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();
}