The attributes frameborder="0" and allowfullscreen cause the w3c validator to fail, i would like to see both of these attributes being implemented as optional via the UI for those times when HTML validation is required regardless.

I have attached a patch that add some additional options for the two iframe attibutes and only adds them to the markup when asked for.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rob Holmes’s picture

Attaching a patch

7drupel7’s picture

Issue summary: View changes

Yes, please make those attributes optional, my W3C validation did not pass either.

andrew.eatherington@gmail.com’s picture

The above patch failed and might be out of date. I've refactored and created a new patch against branch 7.x-2.x.

andrew.eatherington@gmail.com’s picture

This includes additional markup missing from the previous patch.

Rob Holmes’s picture

This issue can be solved by the folowing method without the need for a patch.

function EXAMPLE_video_embed_handler_info_alter(&$handlers) {
  $handlers['youtube']['function'] = '_EXAMPLE_video_embed_field_handle_youtube';
}

Then in _EXAMPLE_video_embed_field_handle_youtube simply place a copy of the original handler taking out any options you dont want rendered, the code below has the width and height options removed.

function _EXAMPLE_video_embed_field_handle_youtube($url, $settings) {
  $output = array();
  // Grab the minutes and seconds, and just convert it down to seconds.
  preg_match('/#t=((?P<min>\d+)m)?((?P<sec>\d+)s)?/', $url, $matches);
  // Give it some default data in case there is no #t=...
  $matches += array(
    "min" => 0,
    "sec" => 0,
  );
  $time = ($matches["min"] * 60) + $matches["sec"];
  $settings['start'] = $time;
  $id = _video_embed_field_get_youtube_id($url);
  if (!$id) {
    // We can't decode the URL - just return the URL as a link.
    $output['#markup'] = l($url, $url);
    return $output;
  }
  // Construct the embed code.
  $settings['wmode'] = 'opaque';
  $settings_str = _video_embed_code_get_settings_str($settings);
  $output['#markup'] = '<iframe title="' . drupal_get_title() . '" src="//www.youtube.com/embed/' . $id . '?' . $settings_str . '"></iframe>';
  return $output;
}
LaravZ’s picture

The same issue persists in Drupal 8, would the fix also work there?

phjou’s picture

@LaravZ I've fixed it for Drupal 8: #3012260 Configure frameborder and allowfullscreen