Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / media / media.api.php
index 8de1c645754b888c7f10ca26680176b1c69b29ff..93244f58a8a11b0450bdeec7b8df18a1e9152c2f 100644 (file)
@@ -20,6 +20,23 @@ function hook_media_source_info_alter(array &$sources) {
   $sources['youtube']['label'] = t('Youtube rocks!');
 }
 
+/**
+ * Alters an oEmbed resource URL before it is fetched.
+ *
+ * @param array $parsed_url
+ *   A parsed URL, as returned by \Drupal\Component\Utility\UrlHelper::parse().
+ * @param \Drupal\media\OEmbed\Provider $provider
+ *   The oEmbed provider for the resource.
+ *
+ * @see \Drupal\media\OEmbed\UrlResolverInterface::getResourceUrl()
+ */
+function hook_oembed_resource_url_alter(array &$parsed_url, \Drupal\media\OEmbed\Provider $provider) {
+  // Always serve YouTube videos from youtube-nocookie.com.
+  if ($provider->getName() === 'YouTube') {
+    $parsed_url['path'] = str_replace('://youtube.com/', '://youtube-nocookie.com/', $parsed_url['path']);
+  }
+}
+
 /**
  * @} End of "addtogroup hooks".
  */