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.

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

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;
}
giupenni’s picture

Very important issue for new Cookie law in EU

enxox’s picture

subscribe

nmillin’s picture

Status: Active » Needs review
StatusFileSize
new1.98 KB

I've added a patch that adds a checkbox that allows people to enable no cookie per video style (example on /admin/config/media/vef/vef_video_styles/list/normal/edit). By default this isn't enabled so there is no functionality change.

upunkt’s picture

@nmillin Thanks for your work, I do appreciate that. Unfortunately it doesn't help against the DoubleClick tracker script but that's Youtube's fault.

giupenni’s picture

#5 work for me.

tfranz’s picture

#5 works for me, too.
But additionally i added the domain 'youtube-nocookie.com' to the allowed domains in line 28 of video_embed_field.handlers.inc :

function video_embed_field_video_embed_handler_info() {
  $handlers = array();

  $handlers['youtube'] = array(
    'title' => 'Youtube',
    'function' => 'video_embed_field_handle_youtube',
    'thumbnail_function' => 'video_embed_field_handle_youtube_thumbnail',
    'thumbnail_default' => drupal_get_path('module', 'video_embed_field') . '/img/youtube.jpg',
    'data_function' => 'video_embed_field_handle_youtube_data',
    'form' => 'video_embed_field_handler_youtube_form',
    'form_validate' => 'video_embed_field_handler_youtube_form_validate',
    'domains' => array(
      'youtube.com',
      'youtu.be',
+      'youtube-nocookie.com',
    ),
upunkt’s picture

To become GDPR compliant we have to deal with the problem that the user IP gets transmitted as soon as a page with an embedded video is loaded, plus data from fonts.gstatic.com and ytimg.com is acquired. A better solution could be what I suggested here:

https://www.drupal.org/project/video_embed_field/issues/2973246#comment-...

I'm not capable to work on this task, though.

anybody’s picture

Status: Needs review » Needs work

We need a rerolled patch from #8

anybody’s picture

Version: 7.x-2.0-beta5 » 7.x-2.x-dev

New patch should be against DEV. To sum up: This is the Drupal 7 issue while the Drupal 8 issue can be found here: #2973246: Youtube Privacy Enhanced Mode (using -nocookie.com) (D8)

bomoko’s picture

StatusFileSize
new2.13 KB

Rerolling patch to include #8

bomoko’s picture

Status: Needs work » Needs review
anybody’s picture

Title: Privacy-enhanced mode for YouTube embed » Privacy-enhanced mode for YouTube embed (D7)
stewest’s picture

stewest’s picture

Status: Needs review » Reviewed & tested by the community
zhouhana’s picture

Actually, even if I type in the URL starting with www.youtube-nocookie.com, the URL that is actually written out in the HTML source becomes www.youtube.com Am I the only one having this issue? If not, this issue is not solved.

zhouhana’s picture

Status: Reviewed & tested by the community » Needs review
helmo’s picture

Status: Needs review » Reviewed & tested by the community

@zhouhana: looks like it, seems to do the trick here.

anybody’s picture

For those who prefer a Two-Click solution may want to have a look at https://www.drupal.org/project/video_embed_mytube

I'd like to see many helping hands, but it already works basically.

chris matthews’s picture

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