<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hey Drupal folks.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Working with Ken Phillips on GDPR/Privacy compliance, I crafted some code for Drupal 8 for preventing cookies from Youtube and Vimeo, and figured I would share it.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
This is for Drupal 8, using its core oEmbed system, and should be universal if you use those:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex;">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
use Drupal\media\IFrameMarkup;</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
use Drupal\media\OEmbed\Provider;</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
/**
<div> * Implements hook_oembed_resource_url_alter().</div>
<div> */</div>
<div>function mymodule_oembed_resource_url_alter(array &$parsed_url, Provider $provider)</div>
<div>{</div>
<div> // Add Do Not Track flag to Vimeo oEmbed requests</div>
<div> if ($provider->getName() === 'Vimeo') {</div>
<div> $parsed_url['query']['dnt'] = true;</div>
<div> }</div>
<div>}</div>
<div><br>
</div>
<div>/**</div>
<div> * Implements hook_preprocess_HOOK().</div>
<div> */</div>
<div>function mymodule_preprocess_media_oembed_iframe(&$variables)</div>
<div>{</div>
<div> // Pull iframe tag </div>
<div> $iFrame = $variables['media']->__toString();</div>
<div> // Switch domain to the youtube nocookie domain.</div>
<div> if (stripos($iFrame, 'youtube.com') !== false){</div>
<div> $newFrame = str_replace('youtube.com/', 'youtube-nocookie.com/', $iFrame);</div>
<div> $variables['media'] = IFrameMarkup::create($newFrame);</div>
<div> }</div>
}<br>
</div>
</blockquote>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hope this helps a few of you. </div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div></div>
<div></div>
<div style="font-family:Tahoma; font-size:13px">
<div style="font-family:Tahoma; font-size:13px">
<div>
<div>
<div>
<div>
<p class="MsoNormal"><img alt="The Ohio State University" style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px; line-height: 18px;" src="http://osu.edu/assets/site/images/logos/osu-emailsig.png"><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px; line-height: 18px;">
<span style="font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); line-height: 18px; color: rgb(187, 0, 0); font-weight: bold;">Richard Hopkins-Lutz</span><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px;">
<span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);">Web Services Manager</span><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px;">
<span style="font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); line-height: 18px; color: rgb(187, 0, 0);">College of Engineering</span><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"> Engineering
Technology Services</span><br style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px;">
<a href="mailto:hopkins-lutz.1@osu.edu" style="font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); line-height: 18px; margin-right: 10px;">hopkins-lutz.1@osu.edu</a><span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255);"> </span><a href="http://osu.edu/" style="font-family: Arial, sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); line-height: 18px;">osu.edu</a><br>
<span style="font-family: Arial, Helvetica, sans-serif; color: rgb(200, 38, 19);">He</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">/</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(200, 38, 19);">Him</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">/</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(200, 38, 19);">His</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(0, 0, 0);">/</span><span style="font-family: Arial, Helvetica, sans-serif; color: rgb(200, 38, 19);">Mr.</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>