Closed as a duplicate of https://www.drupal.org/project/video_embed_field/issues/2913925

Problem/Motivation

Meet WCAG standards for iframe accessability: Using the title attribute of the frame and iframe elements

Proposed resolution

Add a default implementation of renderEmbedCode() in ProviderPluginBase and add provider specific elements in an overriding method in extending classes.

Remaining tasks

This module doesn't test a full render array, so none at present.

User interface changes

No UI visible UI changes but screen readers will now have access to a frame title.

API changes

Code extending the base plugin in custom development would need to be refactored to pick up this change. The change is backwards compatible since this method was not previously implemented at the base class level.

Data model changes

None.

CommentFileSizeAuthor
#52 interdiff-2913598-51-52.txt3.54 KBprudloff
#52 video_embed_field-2913598-52.patch19.43 KBprudloff
#51 2913598-50video-embed-title.patch20.71 KBbyrongary
#49 2913598-49fixes-to-renderoutput-not_container.patch20.91 KBskaught
#48 2913598-48__ally-fixes-to-renderoutput-not_container.patch20.88 KBskaught
#47 2913598-45__ally-fixes-to-renderoutput.patch20.97 KBskaught
#45 2913598-44__ally-fixes-to-renderoutput.patch22.33 KBskaught
#43 2913598-43-move_to_pluginBase-filter_too.patch18.1 KBskaught
#42 2913598-42__dynamic-protocol__better_name-title-id.patch11.18 KBskaught
#41 2913598#41-ssl-protocol-2913598#41_name_id.patch10.38 KBskaught
#40 2913598#40-title att-plus-name_and_id.patch9.48 KBskaught
#38 video_embed_field.permissions.yml142 bytesskaught
#36 video_embed_field-title_attribute-2913598-34.patch10.36 KBkkumaren
#33 video_embed_field-title_attribute-2913598-33.patch10.36 KBjavier_rey
#29 video_embed_field-title_attribute-2913598-29.patch10.18 KBphillamb168
#26 video_embed_field-title_attribute-2913598-26.patch10.11 KBwylbur
#26 video_embed_field-title_attribute-2913598-26.patch10.11 KBwylbur
#23 video_embed_field-title_attribute-2913598-23.patch18.09 KBbdlangton
#22 video_embed_field-title_attribute-2913598-22.patch18.72 KBbdlangton
#21 video_embed_field-title_attribute-2913598-21-8.x-2.x.patch10.74 KBwrd
#20 video_embed_field-title_attribute-2913598-19-v1.5.0-do-not-test.patch293.95 KBleolandotan
#19 video_embed_field-title_attribute-2913598-19.patch293.47 KBleolandotan
#17 interdiff-2913598-13-17.txt4.77 KBleolandotan
#17 video_embed_field-title_attribute-2913598-17.patch26.48 KBleolandotan
#17 2913598-test-case-all-passed.png248.37 KBleolandotan
#15 interdiff-2913598-11-13.txt9.77 KBleolandotan
#14 interdiff-2913598-11-13.txt14.5 KBleolandotan
#14 video_embed_field-title_attribute-2913598-13.patch21.7 KBleolandotan
#11 interdiff-2913598-5-11.txt4.73 KBleolandotan
#11 video_embed_field-title_attribute-2913598-11.patch11.93 KBleolandotan
#8 video_embed_field_patch_issues_2913598.png97.75 KBgeorob
#5 video_embed_field-title_attribute-2913598-5.patch10.64 KBfathershawn
#2 video_embed_field-title_attribute-2913598-2.patch5.54 KBfathershawn
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

FatherShawn created an issue. See original summary.

fathershawn’s picture

Status: Active » Needs review
StatusFileSize
new5.54 KB

This patch was cut against 8.x-1.x but at the moment these files are unchanged in 8.x-2.x so it would apply in both branches.

Status: Needs review » Needs work

The last submitted patch, 2: video_embed_field-title_attribute-2913598-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

fathershawn’s picture

I didn't look deeply enough into the test code. \Drupal\video_embed_field_mock_provider\Plugin\video_embed_field\Provider\MockProvider::renderEmbedCode led me to believe these render arrays weren't tested. I'll update the tests and re-roll.

fathershawn’s picture

Added title values to expected render arrays.

mgifford’s picture

Issue tags: +Accessibility
fathershawn’s picture

I'm not clear on why the test fails :(

georob’s picture

StatusFileSize
new97.75 KB

Reading through the patch for the tests, it looks on the surface that the changes are applied to each attributes section, adding the title for each set.

Weirdly, however, the patch as applied by composer changes the file to add all the title attributes at line 363. See attached screenshot. Could this be the source of the failures?

Screenshot of applied patch #5

fathershawn’s picture

It could be! That's very puzzling.

leolandotan’s picture

Assigned: Unassigned » leolandotan

I'll try to work on this.

leolandotan’s picture

Status: Needs work » Needs review
StatusFileSize
new11.93 KB
new4.73 KB

Here I have implemented the Vimeo implementation that gets the Video title into the Youtube class and updated the test cases to be expecting the title attribute in the iframe already.

Hope everything is in order.

Thanks!

leolandotan’s picture

Assigned: leolandotan » Unassigned

Status: Needs review » Needs work

The last submitted patch, 11: video_embed_field-title_attribute-2913598-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

leolandotan’s picture

Status: Needs work » Needs review
StatusFileSize
new21.7 KB
new14.5 KB

Fixed the test errors to the best of my knowledge.

leolandotan’s picture

StatusFileSize
new9.77 KB

Sorry for the wrong interdiff. This is the right one.

Status: Needs review » Needs work

The last submitted patch, 14: video_embed_field-title_attribute-2913598-13.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

leolandotan’s picture

Status: Needs work » Needs review
StatusFileSize
new248.37 KB
new26.48 KB
new4.77 KB

Additional things done:

  • Fixed the additional errors.
  • Changed the Absolute Beginner's Guide to Drupal(XgYu7-DQjDQ) Youtube video sample to another one Drupal 8 Day: Drupal Commerce in Drupal 8(BmFFPozHKFU) due to missing video. I just replaced the Youtube key directly and didn't change any of embed data i.e. a:6:{s:20:"emvideo_data_version";i:5;s:23:"emvideo_youtube_version";i:5;s:8:"duration";i:0;s:8:"playlist";i:0;s:9:"thumbnail";a:1:{s:3:"url";s:43:"http://img.youtube.com/vi/BmFFPozHKFU/0.jpg";}s:5:"flash";a:3:{s:3:"url";s:32:"http://youtube.com/v/BmFFPozHKFU";s:4:"size";s:1:"0";s:4:"mime";s:29:"application/x-shockwave-flash";}}
  • Updated the test migration content for the zip files.

Test results

2913598 Test case all passed

Status: Needs review » Needs work

The last submitted patch, 17: video_embed_field-title_attribute-2913598-17.patch, failed testing. View results

leolandotan’s picture

Status: Needs work » Needs review
StatusFileSize
new293.47 KB

Fixed the error:

error: cannot apply binary patch to 'tests/fixtures/drupal6-emfield-2-x.php.gz' without full index line
error: tests/fixtures/drupal6-emfield-2-x.php.gz: patch does not apply
error: cannot apply binary patch to 'tests/fixtures/drupal7-vef-2-x.php.gz' without full index line
error: tests/fixtures/drupal7-vef-2-x.php.gz: patch does not apply

The patch for this comment is just about the same as in comment #17 but instead of using:
git diff 8.x-1.x > video_embed_field-title_attribute-2913598-19.patch
I now used:
git diff-index 8.x-1.x --binary > video_embed_field-title_attribute-2913598-19.patch

Additional issues

I'm trying to apply the patch to 8.x-1.5 but it doesn't cleanly apply. I get the following errors:

patching file modules/video_embed_media/tests/src/Functional/BundleTest.php
patching file modules/video_embed_media/tests/src/Kernel/DefaultNameTest.php
patching file modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php
Hunk #1 FAILED at 47.
Hunk #2 FAILED at 79.
2 out of 2 hunks FAILED -- saving rejects to file modules/video_embed_wysiwyg/tests/src/Kernel/FilterTest.php.rej
patching file src/Plugin/video_embed_field/Provider/Vimeo.php
patching file src/Plugin/video_embed_field/Provider/YouTube.php
patching file src/Plugin/video_embed_field/Provider/YouTubePlaylist.php
patching file src/ProviderPluginBase.php
patching file tests/src/Functional/FieldConfigurationTest.php
patching file tests/src/Kernel/Drupal6EmfieldMigrationTest.php
Hunk #1 succeeded at 35 (offset -5 lines).
patching file tests/src/Kernel/Drupal7MigrationTest.php
Hunk #1 succeeded at 64 (offset -5 lines).
patching file tests/src/Kernel/FieldOutputTest.php
Hunk #1 succeeded at 360 (offset 284 lines).
Hunk #2 succeeded at 361 (offset 243 lines).
Hunk #3 succeeded at 362 (offset 201 lines).
Hunk #4 succeeded at 363 (offset 151 lines).
Hunk #5 succeeded at 364 (offset 111 lines).
Hunk #6 FAILED at 421.
Hunk #7 FAILED at 461.
Hunk #8 FAILED at 503.
Hunk #9 succeeded at 365 (offset -95 lines).
Hunk #10 succeeded at 366 (offset -134 lines).
3 out of 10 hunks FAILED -- saving rejects to file tests/src/Kernel/FieldOutputTest.php.rej
patching file tests/src/Unit/ProviderUrlParseTest.php

Any ideas on how to fix this?

Thanks!

leolandotan’s picture

If anyone is interested, I have created a patch as well directed to 8.1.5 because as seen in the previous comment, the 8.x-1.x patch conflicts when applied to 8.1.5 due to other changes already in 8.x-1.x.

This patch contains:

Please feel free to correct me if I needed to create a separate issue for 8.1.5 and just relating it to this issue.

Thanks!

wrd’s picture

For the most part, this patch still applies to 8.x-2.x, failing only on various test files. I've stripped out the patches to test files that failed to apply, and the result appears to work.

bdlangton’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Issue tags: -Accessibility +accessibility
StatusFileSize
new18.72 KB

Patch #21 worked for me. Here is a patch for 8.x-2.x with tests updated to pass.

bdlangton’s picture

Patch #22 doesn't apply to 2.0, so rerolling just for that.

mgifford’s picture

Issue tags: -accessibility (duplicate tag) +Accessibility

Fixing tagging.

gurvan’s picture

I provide a patch in another issue that do the trick https://www.drupal.org/project/video_embed_field/issues/2913925#comment-... (I do that because I work on the project where I also need the patch proposed in this issue

wylbur’s picture

Patch #23 doesn't apply to 2.2, so rerolling just for that!

(disregard the second file, sorry!)

The last submitted patch, 26: video_embed_field-title_attribute-2913598-26.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 26: video_embed_field-title_attribute-2913598-26.patch, failed testing. View results

phillamb168’s picture

Rerolling, I had some issues applying this to 8.7.7

georob’s picture

Status: Needs work » Needs review

This issue seems to be addressed in https://www.drupal.org/project/video_embed_field/issues/2913925. I'd favor closing this issue as a duplicate in favor of that issue, which is currently RTBC, and is more feature complete, where as this issue does a basic job. Hopefully the maintainers can chime in to what they would prefer.

Status: Needs review » Needs work

The last submitted patch, 29: video_embed_field-title_attribute-2913598-29.patch, failed testing. View results

fathershawn’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)

That sounds reasonable. Someone can re-open if needed.

javier_rey’s picture

This same problem occurs for the youtube provider, here is the patch integrating the 2 changes.

javier_rey’s picture

javier_rey’s picture

kkumaren’s picture

#33 is giving a 403 Forbidden. SSL is required to perform this operation.

I've updated the patch to use ssl instead.

alison’s picture

Status: Closed (duplicate) » Closed (won't fix)

Changing to "won't fix," and copying/pasting the note left by the video_embed_field maintainer on other threads, for anyone else who lands here like I did :)

With the advent of Media in core, the Video Embed Field module has moved to being minimally maintained. Only issues which assist in the migration to Media in core will be committed. To read more about this decision, please see: #3089599: Maintenance status for Video Embed Field now that media is in core.

skaught’s picture

StatusFileSize
new142 bytes

^dropped wrong file. oops.

this variant of #29 checks runtime for use of http/s by adding getProtocol() to ProviderPluginBase. let the project decide what it's using @mixed protocols.

A11y: add a unique id and name attributes to iframe per field item.

skaught’s picture

skaught’s picture

ignore this patch. has bad syntax. friday brain (:

skaught’s picture

StatusFileSize
new10.38 KB
skaught’s picture

StatusFileSize
new11.18 KB

post friday cleanup.
set field max-age 0, complete docblock note for new var.

skaught’s picture

StatusFileSize
new18.1 KB

The Video Embed Filter also needs attributes.

skaught’s picture

skaught’s picture

Title: Provide title attribute in iframe tag for accessibility » Accessibility enhancements forhtml output of iframe tag (title, id, name, inner A link)
Status: Closed (won't fix) » Needs review
StatusFileSize
new22.33 KB

include A tag in iframe. change vimeo to use httpClient.

I am working on one of the 60,000 client sites still using this module.... it needs fixes regardless of suggestion to use core media.

skaught’s picture

Title: Accessibility enhancements forhtml output of iframe tag (title, id, name, inner A link) » Accessibility enhancements for html output of iframe tag (title, id, name, inner A link)
skaught’s picture

StatusFileSize
new20.97 KB

44 patch issue.

skaught’s picture

StatusFileSize
new20.88 KB

i'm skipping lint. but fixing container name (oversight)

skaught’s picture

StatusFileSize
new20.91 KB

handle patch with dev head, not release.

skaught’s picture

Issue tags: +Maintenance fixes only
byrongary’s picture

StatusFileSize
new20.71 KB

Reroll for Drupal 10 spaceless tag

prudloff’s picture

StatusFileSize
new19.43 KB
new3.54 KB

The YouTube API refuses non-HTTPS requests and it is a bad practice to call external services without HTTPS.

VincentL made their first commit to this issue’s fork.

herved’s picture

Status: Needs review » Needs work

I see some overlap here with #3200253: Add "title" attribute to YouTube, Vimeo, and Playlist embeds which seems a bit better scoped and ahead in terms of implementation IMHO.
Hence, moving to needs work. I will focus on the other issue for our project needs.

Some observations:

  1. +++ b/src/Plugin/Field/FieldFormatter/Video.php
    @@ -92,21 +92,22 @@ class Video extends FormatterBase implements ContainerFactoryPluginInterface {
    +   		  $element[$delta]['#cache']['max-age'] = 0;
    

    Why do we need to kill the page cache here?

  2. +++ b/src/Plugin/video_embed_field/Provider/Vimeo.php
    @@ -78,7 +72,9 @@ class Vimeo extends ProviderPluginBase {
    +    $title = (($this->oEmbedData() !== FALSE) ? $this->filterCharaters($this->oEmbedData()->title) . ' | ' : '');
    

    This calls oEmbedData() twice, so will fetch twice which could be avoided by caching the response, similar to what is done in #3200253: Add "title" attribute to YouTube, Vimeo, and Playlist embeds

  3. +++ b/src/ProviderPluginInterface.php
    @@ -72,11 +73,13 @@ interface ProviderPluginInterface extends PluginInspectionInterface {
    +  public function renderEmbedCode($width, $height, $autoplay, $instance_id);
    

    This changes the method signature, so breaks backwards compatibility which isn't ideal.

  4. +++ b/src/Plugin/video_embed_field/Provider/Vimeo.php
    @@ -48,11 +37,16 @@ class Vimeo extends ProviderPluginBase {
    +    $data = \json_decode($requestOembed->getBody()->getContents());
    

    I think it would be best to use \Drupal\Component\Serialization\Json::decode

prudloff’s picture

The Twig spaceless filter is deprecated: https://twig.symfony.com/doc/3.x/filters/spaceless.html

The spaceless filter is deprecated as of Twig 3.12. While not a full replacement, you can check the whitespace control features.

prudloff’s picture

Why do we need to kill the page cache here?

Just noticed this as well, it bubbles and disables cache for the entire page.

I see some overlap here with #3200253: Add "title" attribute to YouTube, Vimeo, and Playlist embeds which seems a bit better scoped and ahead in terms of implementation IMHO.

I agree that #3200253: Add "title" attribute to YouTube, Vimeo, and Playlist embeds has the same goal and is more active, closing as duplicate.

prudloff’s picture

Status: Needs work » Closed (duplicate)
prudloff’s picture