Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Resource.php

function Resource::setDimensions

Sets the dimensions.

Parameters

int|null $width: The width of the resource.

int|null $height: The height of the resource.

Throws

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

File

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

Class

Resource
Value object representing an oEmbed resource.

Namespace

Drupal\media\OEmbed

Code

protected function setDimensions($width, $height) {
    if (isset($width) && $width <= 0 || isset($height) && $height <= 0) {
        throw new \InvalidArgumentException('The dimensions must be NULL or numbers greater than zero.');
    }
    $this->width = isset($width) ? (int) $width : NULL;
    $this->height = isset($height) ? (int) $height : NULL;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal