I'm following the documentation and also this example to create a custom OEmbed Finder in my Wagtail site. (Ultimately I want to modify the HTML output for YouTube videos to use the youtube-nocookie.com
domain, rather than youtube.com
.)
I have created this in myapp.embeds.finders.oembed.py
:
from wagtail.embeds.finders.oembed import OEmbedFinder
class YouTubeOEmbedFinder(OEmbedFinder):
def find_embed(self, url, max_width=None):
embed = super().find_embed(url, max_width)
# Just to see that it's doing something:
embed['html'] = '<p>Hello</p>'
return embed
And added this in my settings:
from wagtail.embeds.oembed_providers import youtube
WAGTAILEMBEDS_FINDERS = [
{
'class': 'myapp.embeds.finders.oembed.YouTubeOEmbedFinder',
'providers': [youtube],
},
{
# Handles all other oEmbed providers the default way
'class': 'wagtail.embeds.finders.oembed',
},
]
But nothing is different - the standard YouTube embed is in the published page. As far as I can tell, my find_embed()
method is never called. I must have made some stupid mistake, but I'm stumped.