Forum

Thread tagged as: Addons, Field-Types

YouTube field type and privacy-enhanced mode

There is a YouTube field type in the Perch 2 Add-On archive and i am still using this for my Perch 3 projects. I would like to share a small change I did to the field type. I'm not an expert here but far as I can see this is an improvement.

Background

When generating an embed code directely from a Video on YouTube, there is the option for enabling a "privacy-enhanced mode". This mode makes sure that "When you turn on privacy-enhanced mode, YouTube won’t store information about visitors on your website unless they play the video." (https://support.google.com/youtube/answer/171780?hl=en) Normally YouTube would already get and store user's info if there's a video embedded – without even interacting with it.

When comparing the iframe code generated with or without privacy-enhanced mode switched on, the only difference seems to be the src attribute. ("xyzid" is dummy text for the video ID)

disabled

<iframe width="560" height="315" src="https://www.youtube.com/embed/xyzid" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

enabled

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/xyzid" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

What I did

  • open the file youtube.class.php
  • check out the src attribute in line 48 and 140
  • in both places change https://www.youtube.com/embed/ to https://www.youtube-nocookie.com/embed/
Jonas Fechner

Jonas Fechner 0 points

  • 3 years ago