function Media::getThumbnailHeight

Same name in other branches
  1. 10 core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::getThumbnailHeight()
  2. 11.x core/modules/media/src/Entity/Media.php \Drupal\media\Entity\Media::getThumbnailHeight()

Gets the height of the thumbnail of a media item.

@internal

Parameters

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

Return value

int|null The height of the thumbnail of the media item or NULL if the media is new and the thumbnails are set to be downloaded in a queue.

1 call to Media::getThumbnailHeight()
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 300

Class

Media
Defines the media entity class.

Namespace

Drupal\media\Entity

Code

protected function getThumbnailHeight(bool $from_queue) : ?int {
    $thumbnails_queued = $this->bundle->entity
        ->thumbnailDownloadsAreQueued();
    if ($thumbnails_queued && $this->isNew()) {
        return NULL;
    }
    elseif ($thumbnails_queued && !$from_queue) {
        return $this->get('thumbnail')->height;
    }
    $source = $this->getSource();
    return $source->getMetadata($this, $source->getPluginDefinition()['thumbnail_height_metadata_attribute']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.