Hello
Does anyone know if there is a way to automatically generate a facade for embedded third party media e.g. YouTube video embeds, Twitter/X embeds, etc. using a partial? The kind of thing I’m thinking is something like this:
{{< facade type="youtube" target="2rvWH0g_LoA" width="560" height="315" >}}
Which would generate not only the embed code, but a screenshot which would act as the facade until onmouseover (when the javascript would be loaded) and then on click, would actually load the embed code itself?
@mariothomas In my own case, I’ve broken it down to having a separate shortcode for each source: one for Mastodon (article about that here), one for YouTube that uses Paul Irish’s lite-youtube-embed package (more about that here), etc.. Did it for Twitter, too, but had to abandon that once Musk’s takeover eventually killed off access to the freebie API on which my Twitter shortcodes depended.
My approaches didn’t/don’t go quite as far as what you mention, especially the screenshot method you mentioned, much less put them all together under one facade
shortcode, but perhaps the linked articles will help you down the way to what you want. Remember that the original embed code from each source, other than Mastodon, can create privacy problems for your visitors; my code avoids those issues, but then again also comes well short of what you want. Win some, lose some. 