You are here

public function Audio::thumbnail in Media entity audio 8

Gets thumbnail image.

Media type plugin is responsible for returning URI of the generic thumbnail if no other is available. This functions should always return a valid URI.

Parameters

MediaInterface $media: Media.

Return value

string URI of the thumbnail.

Overrides MediaTypeInterface::thumbnail

File

src/Plugin/MediaEntity/Type/Audio.php, line 69

Class

Audio
Provides media type plugin for Audio.

Namespace

Drupal\media_entity_audio\Plugin\MediaEntity\Type

Code

public function thumbnail(MediaInterface $media) {
  $source_field = $this->configuration['source_field'];

  /** @var \Drupal\file\FileInterface $file */
  if ($file = $media->{$source_field}->entity) {
    return $this->config
      ->get('icon_base') . '/image.png';
  }
  return $this
    ->getDefaultThumbnail();
}