You are here

public function MediaSourceBase::getMetadata in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()
  2. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()
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\media

Code

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