diff --git a/core/modules/media/src/OEmbed/Resource.php b/core/modules/media/src/OEmbed/Resource.php index ac3e7510cd5af3401e04ad6f907d58cc2d7d617c..983f08df28d3c44215a89cccee981498af4b9c48 100644 --- a/core/modules/media/src/OEmbed/Resource.php +++ b/core/modules/media/src/OEmbed/Resource.php @@ -236,7 +236,7 @@ public static function link($url = NULL, Provider $provider = NULL, $title = NUL * @param int $width * The width of the photo, in pixels. * @param int $height - * The height of the photo, in pixels. + * (optional) The height of the photo, in pixels. * @param \Drupal\media\OEmbed\Provider $provider * (optional) The resource provider. * @param string $title @@ -260,7 +260,7 @@ public static function link($url = NULL, Provider $provider = NULL, $title = NUL * * @return static */ - public static function photo($url, $width, $height, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { + public static function photo($url, $width, $height = NULL, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { if (empty($url)) { throw new \InvalidArgumentException('Photo resources must provide a URL.'); } @@ -280,7 +280,7 @@ public static function photo($url, $width, $height, Provider $provider = NULL, $ * @param int $width * The width of the resource, in pixels. * @param int $height - * The height of the resource, in pixels. + * (optional) The height of the resource, in pixels. * @param \Drupal\media\OEmbed\Provider $provider * (optional) The resource provider. * @param string $title @@ -304,7 +304,7 @@ public static function photo($url, $width, $height, Provider $provider = NULL, $ * * @return static */ - public static function rich($html, $width, $height, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { + public static function rich($html, $width, $height = NULL, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { if (empty($html)) { throw new \InvalidArgumentException('The resource must provide an HTML representation.'); } @@ -325,7 +325,7 @@ public static function rich($html, $width, $height, Provider $provider = NULL, $ * @param int $width * The width of the video, in pixels. * @param int $height - * The height of the video, in pixels. + * (optional) The height of the video, in pixels. * @param \Drupal\media\OEmbed\Provider $provider * (optional) The resource provider. * @param string $title @@ -349,7 +349,7 @@ public static function rich($html, $width, $height, Provider $provider = NULL, $ * * @return static */ - public static function video($html, $width, $height, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { + public static function video($html, $width, $height = NULL, Provider $provider = NULL, $title = NULL, $author_name = NULL, $author_url = NULL, $cache_age = NULL, $thumbnail_url = NULL, $thumbnail_width = NULL, $thumbnail_height = NULL) { $resource = static::rich($html, $width, $height, $provider, $title, $author_name, $author_url, $cache_age, $thumbnail_url, $thumbnail_width, $thumbnail_height); $resource->type = self::TYPE_VIDEO; diff --git a/core/modules/media/tests/fixtures/oembed/rich_twitter.json b/core/modules/media/tests/fixtures/oembed/rich_twitter.json index d62ce57a88f175c41555f1520468c70f45c0e517..17bbe1f21e560ada329faadef5fef40b900a4966 100644 --- a/core/modules/media/tests/fixtures/oembed/rich_twitter.json +++ b/core/modules/media/tests/fixtures/oembed/rich_twitter.json @@ -4,7 +4,7 @@ "author_url": "https:\/\/twitter.com\/drupaldevdays", "html": "<h1>By the power of Grayskull, Twitter works!</h1>", "width": 550, - "height": 360, + "height": null, "type": "rich", "cache_age": "3153600000", "provider_name": "Twitter", diff --git a/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php b/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php index e8d9c988b47ecaaa27b250d28ee4325a38192eb4..53f4b40e67ddf0379c1ca8fc2f8c3e8be4e8c540 100644 --- a/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php +++ b/core/modules/media/tests/src/Functional/FieldFormatter/OEmbedFormatterTest.php @@ -98,7 +98,11 @@ public function providerRender() { 'tweet' => [ 'https://twitter.com/drupaldevdays/status/935643039741202432', 'rich_twitter.json', - [], + [ + // The tweet resource does not specify a height, so the formatter + // should default to the configured maximum height. + 'max_height' => 360, + ], [ 'iframe' => [ 'src' => '/media/oembed?url=https%3A//twitter.com/drupaldevdays/status/935643039741202432',