Since we have to comply with the Cookie law in EU, one of the services setting cookies is YouTube. The so called privacy-enhanced mode is acceptable by the law cause it sets cookies after the user starts playing video.

The change in embed code is very small - the src attribute must be from domain youtube-nocookie.com. All the rest is the same.

I found that the embed code is generated in video_embed_field.handlers.inc in function called video_embed_field_handle_youtube($url, $settings).

I'm not very experienced in creating patches but an extra setting and small modification in output could give this functionality. If someone is interested to help on this, I would appreciate it.

Comments

Peter76’s picture

Change on line 111 in file video_embed_field.handlers.inc src="http://www.youtube.com/embed/ to src="http://www.youtube-nocookie.com/embed/.

TS79’s picture

Issue summary:View changes

subscribe
... important setting in EU; I have to overwrite the 'function' handler for youtube at the moment:

function MYMODULE_video_embed_handler_info_alter(&$info) {
  // Change the render function for 'youtube' provider.
  if (isset($info['youtube'])) {
    $info['youtube']['function'] = 'MYMODULE_handle_youtube_alter';
  }
}

/**
* Altered Handler for Youtube videos. (privacy: no cookie usage)
* @see video_embed_field_handle_youtube()
*/
function MYMODULE_handle_youtube_alter($url, $settings) {
  ...
  // Construct the embed code.
  $settings['wmode'] = 'opaque';
  $settings_str = _video_embed_code_get_settings_str($settings);

  // OLD $output['#markup'] = '<iframe width="' . check_plain($settings['width']) . '" height="' . check_plain($settings['height']) . '" src="//www.youtube.com/embed/' . $id . '?' . $settings_str . '" frameborder="0" allowfullscreen></iframe>';

  $output['#markup'] = '<iframe width="' . check_plain($settings['width']) . '" height="' . check_plain($settings['height']) . '" src="//www.youtube-nocookie.com/embed/' . $id . '?' . $settings_str . '" frameborder="0" allowfullscreen></iframe>';

  return $output;
}