protected function EditorMediaDialog::getMediaImageSourceFieldName in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/src/Form/EditorMediaDialog.php \Drupal\media\Form\EditorMediaDialog::getMediaImageSourceFieldName()
- 10 core/modules/media/src/Form/EditorMediaDialog.php \Drupal\media\Form\EditorMediaDialog::getMediaImageSourceFieldName()
Gets the name of an image media item's source field.
Parameters
\Drupal\media\MediaInterface $media: The media item being embedded.
Return value
string|null The name of the image source field configured for the media item, or NULL if the source field is not an image field.
1 call to EditorMediaDialog::getMediaImageSourceFieldName()
- EditorMediaDialog::buildForm in core/
modules/ media/ src/ Form/ EditorMediaDialog.php
File
- core/
modules/ media/ src/ Form/ EditorMediaDialog.php, line 319
Class
- EditorMediaDialog
- Provides a media embed dialog for text editors.
Namespace
Drupal\media\FormCode
protected function getMediaImageSourceFieldName(MediaInterface $media) {
$field_definition = $media
->getSource()
->getSourceFieldDefinition($media->bundle->entity);
$item_class = $field_definition
->getItemDefinition()
->getClass();
if (is_a($item_class, ImageItem::class, TRUE)) {
return $field_definition
->getName();
}
return NULL;
}