function MediaSourceBase::getMetadata

Same name in other branches
  1. 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()
  2. 8.9.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()
  3. 11.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::getMetadata()

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.