Current accessibility requirements state that all iframes on a page must have unique title attributes.

Videlicet:

The function responsible for rendering iframes, theme_video_filter_iframe(), should render the title attribute, if it has been passed via the shortcode.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mark_fullmer created an issue. See original summary.

mark_fullmer’s picture

This patch ensures that, if a user has entered the title:xxx syntax in the shortcode, it will be included in the rendered attributes of all codecs which use the iframe. User input will be sanitized in the subsequent call to drupal_attributes().

mark_fullmer’s picture

mark_fullmer’s picture

Issue summary: View changes
mgifford’s picture

Makes sense to me. Quick read of the patch looks ok. Mind you I don't know this module.

mark_fullmer’s picture

FileSize
1.14 KB

Upon further testing, I noticed that the existing regex does not account for spaces between words in shortcode parameters. Title attributes likely *would* contain spaces. Therefore, I've refactored the regex expression to find either a string of format xxx:xxx (no spaces) OR xxx:"xxx xxx" (the double quotes are required).

This should receive careful review by the module maintainer, since we don't want to adversely affect other elements that this regex parses. However, my testing of the generic equivalent preg_match_all("/\s+([a-zA-Z_]+)\:(\s+)?(([0-9a-zA-Z\/]+)|(\"([0-9a-zA-Z\s]*)\"))/i", $input_lines, $output_array); does work as expected for the following test cases:

test:1 title:"foo"
test:string title:"foo baz"
test:string title:"foo baz" width:300

cleverington’s picture

Status: Needs review » Needs work

Two things:

Title cannot be last

Tested and regex only picks up the 'first' word if the title attribute is the last item in the row.
For example:
Fails:[video:test:1 align:center title:"Some Title Text"]
Only loads: "Some"
Passes: [video:test:1 title:"Some Title Text" align:center]
Loads: "Some Title Text"

Upgrading the Overall Module

Though useful, the patch would probably serve a better UI/UX (and be used more) to also update.

Meeting in ten, so I know the code is completely invalid (there is no hook_update or hook_form_alter, etc.), but you get the idea.

_video_filter_form could be changed with a new field:

  $form['video_filter']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#maxlength' => 255,
    '#size' => 80,
    '#default_value' => '',
    '#weight' => 6,
  );

Then, within _video_filter_process, make a slight alteration:

      $video = array(
        'source' => $matches_code[2][$ci],
        'autoplay' => $filter->settings['video_filter_autoplay'],
        'related' => $filter->settings['video_filter_related'],
        'title' => $filter->settings['video_filter_title'],    <---- Right here?
      );

Though it might be a large endeavor, as it looks like the files within editors/ will each need adjustment to fix the editor forms.

cleverington’s picture

Adding a tweak to Patch 6 (based on my comments from comment-7) which adds a data-entry field for the title attribute within each CKEditor.

Works in Chrome perfectly, but seems to fail on FireFox and Safari in placing the added code within the CKEditor field.

This could be an issue with CKEditor's caching though....

Didn't test the tweaks on either TinyMCE and/or fckeditor.

Next step seems like it would be prudent to revise the Codecs to retrieve and populate the title attribute for the user.

liquidcms’s picture

thanks for adding this, but.. patch is referenced from wrong location. It should be based from the module's directory, not from /modules

but even fixing this the patch fails in 3 places.. but this was with 7.x-3.4, possibly it is against 7.x-3.x

liquidcms’s picture

yes, it seems to apply to -dev; but doesn't work (no title is added from the shortcode).. also, -dev seems to be broken on its own.

liquidcms’s picture

FileSize
1.63 KB

As i couldn't get patch to work and mainly because my client didn't want to rely on editors filling in the title with the token, i created this small filter module which pulls the actual title from the video provider (only for YouTube and Vimeo, but likely works elsewhere) and adds as the iframe's title attr.

This works alongside (technically, "after") the video filter but will also work on any manually inserted video iframe (although not sure why someone would do that).

mgifford’s picture

Thanks Peter.

xeM8VfDh’s picture

Is this issue dead? This is causing accessibility issues on my site as well. @liquidcms's module looks cool, but alas, I'm using D8.

mark_fullmer’s picture

One workaround for this would be to use the iFrame Title Filter module -- just have it set to run after the video filter in your text format filter processing order.

xeM8VfDh’s picture

Thanks for the suggestion @mark_fullmer

Still wondering if a contributor can chime in to answer whether core will address this issue. Seems perfectly suitable for core functionality and shouldn't require a module (but good to know that there is one available if need be, though it does seem to be inactive).

Michelle’s picture

Status: Needs work » Needs review
FileSize
5.82 KB

This patch is based on the one in #8. I looked at that and manually applied the changes to the latest dev and then made fixes to make it work. Note that I only added the CKEditor parts since that's what I needed. The other editors' parts will need to be added and tested for this to be a total solution. But this is working for CKEditor, at least.

DamienMcKenna’s picture

Assigned: mark_fullmer » Unassigned
DamienMcKenna’s picture

Status: Needs review » Needs work

Might anyone be able to port Michelle's improvements to TinyMCE? Thanks.