Issue #3021452 by Luke.Leber, jibran, ericmulder1980, phenaproxima, Martijn de Wit, alexpott, andrewmacpherson, marcoscano, pawandubey, seanB, lauriii: Add title attribute to oEmbed iframe for accessibility
							parent
							
								
									5cd49004e4
								
							
						
					
					
						commit
						23aa83870b
					
				| 
						 | 
				
			
			@ -229,6 +229,13 @@ class OEmbedFormatter extends FormatterBase implements ContainerFactoryPluginInt
 | 
			
		|||
          ],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        // An empty title attribute will disable title inheritance, so only
 | 
			
		||||
        // add it if the resource has a title.
 | 
			
		||||
        $title = $resource->getTitle();
 | 
			
		||||
        if ($title) {
 | 
			
		||||
          $element[$delta]['#attributes']['title'] = $title;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        CacheableMetadata::createFromObject($resource)
 | 
			
		||||
          ->addCacheTags($this->config->getCacheTags())
 | 
			
		||||
          ->applyTo($element[$delta]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html lang="de">
 | 
			
		||||
<head>
 | 
			
		||||
    <link rel="alternate" href="video_vimeo-no-title.json"
 | 
			
		||||
          type="application/json+oembed" title="">
 | 
			
		||||
</head>
 | 
			
		||||
<body></body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,16 @@
 | 
			
		|||
{
 | 
			
		||||
  "type": "video",
 | 
			
		||||
  "version": "1.0",
 | 
			
		||||
  "provider_name": "Vimeo",
 | 
			
		||||
  "provider_url": "https:\/\/vimeo.com\/",
 | 
			
		||||
  "title": "",
 | 
			
		||||
  "author_name": "Tendenci - The Open Source AMS",
 | 
			
		||||
  "author_url": "https:\/\/vimeo.com\/schipul",
 | 
			
		||||
  "html": "<iframe width=\"480\">By the power of Greyskull, Vimeo works!</iframe>",
 | 
			
		||||
  "width": 480,
 | 
			
		||||
  "height": 360,
 | 
			
		||||
  "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": 295,
 | 
			
		||||
  "thumbnail_height": 221
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -58,20 +58,35 @@ class OEmbedFormatterTest extends MediaFunctionalTestBase {
 | 
			
		|||
        [
 | 
			
		||||
          'iframe' => [
 | 
			
		||||
            'src' => '/media/oembed?url=https%3A//vimeo.com/7073899',
 | 
			
		||||
            'width' => 480,
 | 
			
		||||
            'height' => 360,
 | 
			
		||||
            'width' => '480',
 | 
			
		||||
            'height' => '360',
 | 
			
		||||
            'title' => 'Drupal Rap Video - Schipulcon09',
 | 
			
		||||
          ],
 | 
			
		||||
        ],
 | 
			
		||||
      ],
 | 
			
		||||
      'Vimeo video, resized' => [
 | 
			
		||||
        'https://vimeo.com/7073899',
 | 
			
		||||
        'video_vimeo.json?maxwidth=100&maxheight=100',
 | 
			
		||||
        ['max_width' => 100, 'max_height' => 100],
 | 
			
		||||
        ['max_width' => '100', 'max_height' => '100'],
 | 
			
		||||
        [
 | 
			
		||||
          'iframe' => [
 | 
			
		||||
            'src' => '/media/oembed?url=https%3A//vimeo.com/7073899',
 | 
			
		||||
            'width' => 100,
 | 
			
		||||
            'height' => 100,
 | 
			
		||||
            'width' => '100',
 | 
			
		||||
            'height' => '100',
 | 
			
		||||
            'title' => 'Drupal Rap Video - Schipulcon09',
 | 
			
		||||
          ],
 | 
			
		||||
        ],
 | 
			
		||||
      ],
 | 
			
		||||
      'Vimeo video, no title' => [
 | 
			
		||||
        'https://vimeo.com/7073899',
 | 
			
		||||
        'video_vimeo-no-title.json',
 | 
			
		||||
        [],
 | 
			
		||||
        [
 | 
			
		||||
          'iframe' => [
 | 
			
		||||
            'src' => '/media/oembed?url=https%3A//vimeo.com/7073899',
 | 
			
		||||
            'width' => '480',
 | 
			
		||||
            'height' => '360',
 | 
			
		||||
            'title' => NULL,
 | 
			
		||||
          ],
 | 
			
		||||
        ],
 | 
			
		||||
      ],
 | 
			
		||||
| 
						 | 
				
			
			@ -82,8 +97,8 @@ class OEmbedFormatterTest extends MediaFunctionalTestBase {
 | 
			
		|||
        [
 | 
			
		||||
          'iframe' => [
 | 
			
		||||
            'src' => '/media/oembed?url=https%3A//twitter.com/drupaldevdays/status/935643039741202432',
 | 
			
		||||
            'width' => 550,
 | 
			
		||||
            'height' => 360,
 | 
			
		||||
            'width' => '550',
 | 
			
		||||
            'height' => '360',
 | 
			
		||||
          ],
 | 
			
		||||
        ],
 | 
			
		||||
      ],
 | 
			
		||||
| 
						 | 
				
			
			@ -94,8 +109,8 @@ class OEmbedFormatterTest extends MediaFunctionalTestBase {
 | 
			
		|||
        [
 | 
			
		||||
          'img' => [
 | 
			
		||||
            'src' => '/core/misc/druplicon.png',
 | 
			
		||||
            'width' => 88,
 | 
			
		||||
            'height' => 100,
 | 
			
		||||
            'width' => '88',
 | 
			
		||||
            'height' => '100',
 | 
			
		||||
          ],
 | 
			
		||||
        ],
 | 
			
		||||
      ],
 | 
			
		||||
| 
						 | 
				
			
			@ -171,8 +186,14 @@ class OEmbedFormatterTest extends MediaFunctionalTestBase {
 | 
			
		|||
    $assert = $this->assertSession();
 | 
			
		||||
    $assert->statusCodeEquals(200);
 | 
			
		||||
    foreach ($selectors as $selector => $attributes) {
 | 
			
		||||
      $element = $assert->elementExists('css', $selector);
 | 
			
		||||
      foreach ($attributes as $attribute => $value) {
 | 
			
		||||
        $assert->elementAttributeContains('css', $selector, $attribute, $value);
 | 
			
		||||
        if (isset($value)) {
 | 
			
		||||
          $this->assertContains($value, $element->getAttribute($attribute));
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
          $this->assertFalse($element->hasAttribute($attribute));
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue