Unverified Commit b6bb2de8 authored by webchick's avatar webchick Committed by lauriii

Issue #3021452 by Luke.Leber, jibran, ericmulder1980, phenaproxima, Martijn de...

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

(cherry picked from commit 23aa8387)
parent 7fea7911
......@@ -229,6 +229,13 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
],
];
// 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]);
......
<!DOCTYPE html>
<html lang="de">
<head>
<link rel="alternate" href="video_vimeo-no-title.json"
type="application/json+oembed" title="">
</head>
<body></body>
</html>
{
"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 @@ public function providerRender() {
[
'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 @@ public function providerRender() {
[
'iframe' => [
'src' => '/media/oembed?url=https%3A//twitter.com/drupaldevdays/status/935643039741202432',
'width' => 550,
'height' => 360,
'width' => '550',
'height' => '360',
],
],
],
......@@ -94,8 +109,8 @@ public function providerRender() {
[
'img' => [
'src' => '/core/misc/druplicon.png',
'width' => 88,
'height' => 100,
'width' => '88',
'height' => '100',
],
],
],
......@@ -171,8 +186,14 @@ public function testRender($url, $resource_url, array $formatter_settings, array
$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));
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment