You are here

protected function Media::getThumbnailUri in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::getThumbnailUri()
  2. 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.

1 call to Media::getThumbnailUri()
Media::updateThumbnail in core/modules/media/src/Entity/Media.php
Update the thumbnail for 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']);
}