You are here

protected function Media::getThumbnailUri in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::getThumbnailUri()

Gets the URI for the thumbnail of a media item.

If thumbnail fetching is queued, new media items will use the default thumbnail, and existing media items will use the current thumbnail, until the queue is processed and the updated thumbnail has been fetched. Otherwise, the new thumbnail will be fetched immediately.

@internal

Parameters

bool $from_queue: Specifies whether the thumbnail is being fetched from the queue.

Return value

string The file URI for the thumbnail of the media item.

File

core/modules/media/src/Entity/Media.php, line 248

Class

Media
Defines the media entity class.

Namespace

Drupal\media\Entity

Code

protected function getThumbnailUri($from_queue) {
  $thumbnails_queued = $this->bundle->entity
    ->thumbnailDownloadsAreQueued();
  if ($thumbnails_queued && $this
    ->isNew()) {
    return $this
      ->getDefaultThumbnailUri();
  }
  elseif ($thumbnails_queued && !$from_queue) {
    return $this
      ->get('thumbnail')->entity
      ->getFileUri();
  }
  $source = $this
    ->getSource();
  return $source
    ->getMetadata($this, $source
    ->getPluginDefinition()['thumbnail_uri_metadata_attribute']);
}