Unverified Commit f87d33ac authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2966043 by phenaproxima, owenbush, a.dmitriiev, marcoscano, tapscolaM,...

Issue #2966043 by phenaproxima, owenbush, a.dmitriiev, marcoscano, tapscolaM, xtineroque, ramya.shankaralingam: Handle oEmbed resources without an explicit height
parent fd58fbe7
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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;

+1 −1
Original line number Diff line number Diff line
@@ -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",
+5 −1
Original line number Diff line number Diff line
@@ -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',