Better privacy for youtube videos

Created on 27 March 2019, over 5 years ago
Updated 12 April 2024, 3 months ago

My suggestion:

It would be great if we can select a nocookie-checkbox in the video_oembed media entity. With this, all youtube urls change automatic to youtube-nocookie.com urls.

Why automatically?
Because users copy the wrong URLs from youtube.

Source:
https://dri.es/how-to-remove-youtube-tracking

A step further:
Another approach for more privacy is this wordpress-variant:
https://de.wordpress.org/plugins/wp-youtube-lyte/

✨ Feature request
Status

Active

Version

11.0 🔥

Component
Media  →

Last updated about 3 hours ago

Created by

🇨🇭Switzerland handkerchief

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇹Italy FiNeX

    Thanks for #35 :-)

  • 🇺🇸United States Chris Matthews
  • 🇩🇪Germany marcoka

    Just FYI if you switch to the nocookie domain cookies get still loaded, external fonts.
    Even if you link the hir-es image from youtube directly cookies are set.
    The only solutions seems to be to load and use the thumb oembed itself stores in the oembed folder in /files

  • 🇨🇭Switzerland ytsurk Switzerland

    I also decided (again) to go with a custom solution .. using data-src, the oembed thumbnail and the no-cookie domain.
    (Not using a consent banner, so the cookies module seemed to heavy for me, although I did not tried)

    But still I would welcome the no-cookie domain and the vimeo setting toggle (aka more privacy) for core's external video media type!

  • 🇲🇽Mexico luisnicg

    I applied the hook that Berdir shared in the first comment but I had to complement the solution by passing the entity id to the iframe controller, that way I was able to load the media entity data. In my case I added a custom field to my Remote Video media type to determine whether to replace youtube.com by youtube-nocookie.com or not.

    use Drupal\media\IFrameMarkup;
    
    /**
     * Implements hook_preprocess_media_oembed_iframe().
     */
    function mymodule_updates_preprocess_media_oembed_iframe(array &$variables) {
      if (strpos((string) $variables['media'], 'youtube.com') !== FALSE) {
        $entity_id = $variables['entity_id'];
        $remote_video = \Drupal::entityTypeManager()->getStorage('media')->load($entity_id);
        $no_cookies = $remote_video->get('field_nocookies')->value;
        if ($no_cookies) {
          $variables['media'] = IFrameMarkup::create(str_replace('youtube.com/', 'youtube-nocookie.com/', $variables['media']));
        }
      }
    }
    
Production build 0.69.0 2024