You are here

public function MediaImage::getFieldDefinition in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getFieldDefinition()
  2. 8 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getFieldDefinition()
  3. 8.2 src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php \Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay\MediaImage::getFieldDefinition()

Get the FieldDefinition object required to render this field's formatter.

Return value

\Drupal\Core\Field\BaseFieldDefinition The field definition.

Overrides EntityReferenceFieldFormatter::getFieldDefinition

See also

\Drupal\entity_embed\FieldFormatterEntityEmbedDisplayBase::build()

File

src/Plugin/entity_embed/EntityEmbedDisplay/MediaImage.php, line 74

Class

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

Namespace

Drupal\lightning_media\Plugin\entity_embed\EntityEmbedDisplay

Code

public function getFieldDefinition() {

  // The parent method will set the target_type to the entity type being
  // embedded, but we are actually rendering an image (i.e., a file entity).
  return parent::getFieldDefinition()
    ->setSetting('target_type', 'file');
}