Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In youtube, there's an option to use privacy-mode, where cookies are disabled for the guests of your site that play the video.
Here's the standard code:
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/lEXZ2hfD3bU&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/lEXZ2hfD3bU&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
As opposed to privacy mode, where the domain changes to www.youtube-nocookie.com, but everything else stays the same.
<object width="640" height="385"><param name="movie" value="http://www.youtube-nocookie.com/v/lEXZ2hfD3bU&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/lEXZ2hfD3bU&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
Ideally, the site would accept either type of embed code and allow the site administrator to override them all to privacy mode or non privacy mode. I see a simple str_replace() as able to achieve this functionality. What do you think?
Comment | File | Size | Author |
---|---|---|---|
#4 | media_youtube-privacy-764646-4.patch | 10.24 KB | bsevere |
Comments
Comment #1
timwoodSub. I have a need for this option on a Federal government site. Preferably it would be an option exposed on the admin/settings/media_youtube settings screen. Perhaps in the YouTube video player options section.
Thanks!
Comment #2
timwoodHere is the FAQ page on Youtube about the feature. I briefly tried to make the modifications to the 1.2 branch I downloaded, but the changes needed in themes/media_youtube.theme.inc were beyond my programming ability. This youtube option is a bit more complicated then, for example the HD option, because it changes the domain the embedded media is coming from (www.youtube.com vs www.youtube-nocookie.com).
Comment #3
WebJohn CreditAttribution: WebJohn commentedBumping this up since it's still an issue in 1.3. This is also more of an issue since the EU Cookie Regulations have now come in to force. Having this option as a tick-box when adding media to a piece of content would be great - or having this as a global setting that would apply to all YouTube embeds.
Comment #4
bsevere CreditAttribution: bsevere commentedWe created a patch for our production environment some time ago (pre git). It applied to version 6.x-1.3 and it worked for our purposes. I have recreated the patch for dev version.
We followed the global setting path. Our users are expected to know which videos need to be privacy-enabled and use the appropriate embed code when saving a new video. The patch allows the media_youtube module to detect the embed code settings for each video and present them accordingly.
We also had a need for the https option and that is included in this patch as well.
Comment #5
bsevere CreditAttribution: bsevere commentedsetting status to needs review.
Comment #6
RobW CreditAttribution: RobW commentedFor 7.x-2.x, I added this option in the patch here: #1555276: Clean up theming function, Use recommended iframe player by default, without js.
Comment #7
Mschudders CreditAttribution: Mschudders commentedI have also needed to add this :
'@youtube-nocookie\.com/(?:v|embed)/([^"\&\? ]+)@i',
in
function emvideo_youtube_extract($video_id = '')