public function MediaSourceBase::getMetadata in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()
Gets the value for a metadata attribute for a given media item.
Parameters
\Drupal\media\MediaInterface $media: A media item.
string $attribute_name: Name of the attribute to fetch.
Return value
mixed|null Metadata attribute value or NULL if unavailable.
Overrides MediaSourceInterface::getMetadata
3 calls to MediaSourceBase::getMetadata()
- File::getMetadata in core/
modules/ media/ src/ Plugin/ media/ Source/ File.php - Gets the value for a metadata attribute for a given media item.
- OEmbed::getMetadata in core/
modules/ media/ src/ Plugin/ media/ Source/ OEmbed.php - Gets the value for a metadata attribute for a given media item.
- Test::getMetadata in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ Test.php - Gets the value for a metadata attribute for a given media item.
3 methods override MediaSourceBase::getMetadata()
- File::getMetadata in core/
modules/ media/ src/ Plugin/ media/ Source/ File.php - Gets the value for a metadata attribute for a given media item.
- OEmbed::getMetadata in core/
modules/ media/ src/ Plugin/ media/ Source/ OEmbed.php - Gets the value for a metadata attribute for a given media item.
- Test::getMetadata in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ Test.php - Gets the value for a metadata attribute for a given media item.
File
- core/
modules/ media/ src/ MediaSourceBase.php, line 130
Class
- MediaSourceBase
- Base implementation of media source plugin.
Namespace
Drupal\mediaCode
public function getMetadata(MediaInterface $media, $attribute_name) {
switch ($attribute_name) {
case 'default_name':
return 'media:' . $media
->bundle() . ':' . $media
->uuid();
case 'thumbnail_uri':
$default_thumbnail_filename = $this->pluginDefinition['default_thumbnail_filename'];
return $this->configFactory
->get('media.settings')
->get('icon_base_uri') . '/' . $default_thumbnail_filename;
}
return NULL;
}