protected function MediaImageDecorator::getMediaImageSourceField in Entity Embed 8
Get image field from source config.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Embedded entity.
Return value
string|null String of image field name.
3 calls to MediaImageDecorator::getMediaImageSourceField()
- MediaImageDecorator::build in src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImageDecorator.php - Builds the renderable array for this Entity Embed display plugin.
- MediaImageDecorator::buildConfigurationForm in src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImageDecorator.php - Form constructor.
- MediaImageDecorator::submitConfigurationForm in src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImageDecorator.php - Form submission handler.
File
- src/
Plugin/ entity_embed/ EntityEmbedDisplay/ MediaImageDecorator.php, line 244
Class
- MediaImageDecorator
- Decorator on all EntityEmbedDisplays that adds alt and title overriding.
Namespace
Drupal\entity_embed\Plugin\entity_embed\EntityEmbedDisplayCode
protected function getMediaImageSourceField(EntityInterface $entity) {
if (!$entity instanceof MediaInterface) {
return NULL;
}
$field_definition = $entity
->getSource()
->getSourceFieldDefinition($entity->bundle->entity);
$item_class = $field_definition
->getItemDefinition()
->getClass();
if ($item_class == ImageItem::class || is_subclass_of($item_class, ImageItem::class)) {
return $field_definition
->getName();
}
return NULL;
}