function Resource::setThumbnailDimensions

Same name in other branches
  1. 9 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::setThumbnailDimensions()
  2. 8.9.x core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::setThumbnailDimensions()
  3. 10 core/modules/media/src/OEmbed/Resource.php \Drupal\media\OEmbed\Resource::setThumbnailDimensions()

Sets the thumbnail dimensions.

Parameters

int $width: The width of the resource.

int $height: The height of the resource.

Throws

\InvalidArgumentException If either $width or $height are not numbers greater than zero.

1 call to Resource::setThumbnailDimensions()
Resource::__construct in core/modules/media/src/OEmbed/Resource.php
Resource constructor.

File

core/modules/media/src/OEmbed/Resource.php, line 497

Class

Resource
Value object representing an oEmbed resource.

Namespace

Drupal\media\OEmbed

Code

protected function setThumbnailDimensions($width, $height) {
    $width = (int) $width;
    $height = (int) $height;
    if ($width > 0 && $height > 0) {
        $this->thumbnailWidth = $width;
        $this->thumbnailHeight = $height;
    }
    else {
        throw new \InvalidArgumentException('The thumbnail dimensions must be numbers greater than zero.');
    }
}

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