Verified Commit 5559dba9 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #2966656 by imclean, smustgrave, phenaproxima, cilefen: Negotiate max...

Issue #2966656 by imclean, smustgrave, phenaproxima, cilefen: Negotiate max width/height of oEmbed assets more intelligently
parent db76de26
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -197,8 +197,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
        $element[$delta] = [
          '#theme' => 'image',
          '#uri' => $resource->getUrl()->toString(),
          '#width' => $max_width ?: $resource->getWidth(),
          '#height' => $max_height ?: $resource->getHeight(),
          '#width' => $resource->getWidth(),
          '#height' => $resource->getHeight(),
          '#attributes' => [
            'loading' => $this->getSetting('loading')['attribute'],
          ],
@@ -230,8 +230,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
            'frameborder' => 0,
            'scrolling' => FALSE,
            'allowtransparency' => TRUE,
            'width' => $max_width ?: $resource->getWidth(),
            'height' => $max_height ?: $resource->getHeight(),
            // External service is not supposed to send something larger
            // than the max width or max height, so those values should be used.
            'width' => $resource->getWidth() ?: $max_width,
            'height' => $resource->getHeight() ?: $max_height,
            'class' => ['media-oembed-content'],
            'loading' => $this->getSetting('loading')['attribute'],
          ],
+8 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html lang="de">
<head>
  <link rel="alternate" href="video_vimeo-resized.json"
        type="application/json+oembed" title="Drupal Rap Video - Schipulcon09">
</head>
<body></body>
</html>
+16 −0
Original line number Diff line number Diff line
{
  "type": "video",
  "version": "1.0",
  "provider_name": "Vimeo",
  "provider_url": "https:\/\/vimeo.com\/",
  "title": "Drupal Rap Video - Schipulcon09",
  "author_name": "Tendenci - The Open Source AMS",
  "author_url": "https:\/\/vimeo.com\/schipul",
  "html": "<iframe width=\"100\">By the power of Grayskull, Vimeo works!</iframe>",
  "width": 100,
  "height": 67,
  "description": "Special thanks to Tendenci, formerly Schipul for sponsoring this video with training, equipment and time. The open source way. All creative however was self directed by the individuals - A. Hughes (www.schipul.com\/ahughes) featuring QCait (www.schipul.com\/qcait) - Hands On Drupal\n\nDrupal is a free software package that allows an individual or a community of users to easily publish, manage and organize a wide variety of content on a website.\n\nNeed a little Drupal help or just want to geek out with us?  Visit our www.schipul.com\/drupal for more info - we'd love to connect!\n\nGo here for Drupal Common Terms and Suggested Modules : http:\/\/schipul.com\/en\/helpfiles\/v\/229",
  "thumbnail_url": "internal:\/core\/misc\/druplicon.png",
  "thumbnail_width": 100,
  "thumbnail_height": 67
}
+3 −3
Original line number Diff line number Diff line
@@ -78,13 +78,13 @@ public static function providerRender() {
      ],
      'Vimeo video, resized' => [
        'https://vimeo.com/7073899',
        'video_vimeo.json?maxwidth=100&maxheight=100',
        'video_vimeo-resized.json',
        ['max_width' => '100', 'max_height' => '100'],
        [
          'iframe' => [
            'src' => '/media/oembed?url=https%3A//vimeo.com/7073899',
            'src' => '/media/oembed?url=https%3A//vimeo.com/7073899&max_width=100&max_height=100',
            'width' => '100',
            'height' => '100',
            'height' => '67',
            'title' => 'Drupal Rap Video - Schipulcon09',
            'loading' => 'lazy',
          ],
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public function testMediaOEmbedVideoSource() {
    $this->assertSame($video_url, $query['url']);
    $this->assertNotEmpty($query['hash']);
    // Ensure that the outer iframe's width respects the formatter settings.
    $this->assertSame('240', $iframe->getAttribute('width'));
    $this->assertSame('480', $iframe->getAttribute('width'));
    // Check the inner iframe to make sure that CSS has been applied to scale it
    // correctly, regardless of whatever its width attribute may be (the fixture
    // hard-codes it to 480).