You are here

public function Image::thumbnail in Media entity image 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/Image.php, line 207

Class

Image
Provides media type plugin for Image.

Namespace

Drupal\media_entity_image\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 $file
      ->getFileUri();
  }
  return $this
    ->getDefaultThumbnail();
}