Hi, I think this module is exactly what I need, but I just cannot get it to work in the way I expect.
I have a site with oembed using https://youtu.be/ style links, but would like to switch the domain sitewide for https://www.youtube-nocookie.com/
I had originally thought I could just alter the output somewhere, but all the validation gets in the way. Therefore I found this module and wanted to use it to create a new oembed provider for this nocookie domain, but I just cannot seem to get it to work.
Has anyone done anything for youtube-nocookie already that could help me through the steps? In my module I have the below code within the hook, and it appears in the "bucket" page, but how do I make it an option on the field settings page?
$providers[] = [
'provider_name' => 'YouTube NoCookie',
'provider_url' => 'https://www.youtube-nocookie.com/',
'endpoints' => [
[
'schemes' => [
'https://www.youtube-nocookie.com/*'
],
'url' => 'https://www.youtube-nocookie.com/oembed',
'discovery' => 'true',
],
],
];
Also, I did some hacking to just see if this would work in theory, and it kept telling me this wasn't valid oembed, now my issue above may help with that, but is there a way to confirm if this is a vali oembed path?
Thanks for your time and help,
Dan
Comments
Comment #2
chris burge commentedThe 'provider_name' in the provider definition must match the 'provider_name' from the resource response.
Here's an example oEmbed request to www.youtube-nocookie.com:
https://www.youtube-nocookie.com/oembed?url=https://www.youtube.com/watch?v=7SqirKJ2AK0Here's the response:
The problem is that while YouTube responds to oEmbed requests to
www.youtube-nocookie.com, it responds as if the request had been sent towww.youtube.com. You're not going to get an embed code withwww.youtube-nocookie.comas the domain. It's just how Google has its oEmbed service designed. You could create a custom provider that includeshttp://www.youtube-nocookie.com/*andhttps://www.youtube-nocookie.com/*as schemes. That would at least allow your users to submit YouTube URLs fromwww.youtube-nocookie.com. Just know, the embed code returned will be forwww.youtube.comand not forwww.youtube-nocookie.com.Comment #3
retrodans commentedThanks for your help @chris-burge sadly we are after rendering youtube-nocookie on the site.
So it sounds like if we want to you youtube-nocookie to render the media, then we would have to switch things to use something other than oembed (at least for the time being).
My current idea would be to write a custom formatter than instead of using oEmbed, would just create the embed code (with some regex replaces for the domain). As it would only be on our site, we should be able to make a few assumptions to get this to work. Before I proceed, doe you feel this seems like a sane approach, or would you have other approaches worth me looking into?
Thanks again for your time,
Dan
Comment #4
chris burge commentedEither of those could work. Before oEmbed, I had written a custom module that provided a text filter (e.g. extended
Drupal\filter\Plugin\FilterBase). It basically worked like a WP short code.Take a look at #3043821: Better privacy for youtube videos, specifically comment #35.
Comment #5
chris burge commented