function File::getMetadata
Overrides MediaSourceBase::getMetadata
1 call to File::getMetadata()
- Image::getMetadata in core/modules/ media/ src/ Plugin/ media/ Source/ Image.php 
- Gets the value for a metadata attribute for a given media item.
1 method overrides File::getMetadata()
- Image::getMetadata in core/modules/ media/ src/ Plugin/ media/ Source/ Image.php 
- Gets the value for a metadata attribute for a given media item.
File
- 
              core/modules/ media/ src/ Plugin/ media/ Source/ File.php, line 60 
Class
- File
- File entity media source.
Namespace
Drupal\media\Plugin\media\SourceCode
public function getMetadata(MediaInterface $media, $attribute_name) {
  /** @var \Drupal\file\FileInterface $file */
  $file = $media->get($this->configuration['source_field'])->entity;
  // If the source field is not required, it may be empty.
  if (!$file) {
    return parent::getMetadata($media, $attribute_name);
  }
  switch ($attribute_name) {
    case static::METADATA_ATTRIBUTE_NAME:
    case 'default_name':
      return $file->getFilename();
    case static::METADATA_ATTRIBUTE_MIME:
      return $file->getMimeType();
    case static::METADATA_ATTRIBUTE_SIZE:
      return $file->getSize();
    case 'thumbnail_uri':
      return $this->getThumbnail($file) ?: parent::getMetadata($media, $attribute_name);
    default:
      return parent::getMetadata($media, $attribute_name);
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
