I use a lot of embedded videos (via oembed
) on my blog, and that can slow down page loads.
Is there a way to automatically replace YouTube (and other) videos with a thumbnail (preferably the post’s featured image). And then replace the thumbnail with the video iframe when clicked?
Notes
<iframe>
and<img>
sizes, other oEmbeds.Sources of Inspiration
oEmbed
oEmbed, thumbnails and wordpress
Replace Image with Embed
https://stackoverflow.com/q/838878/1287812
Plugin
Contents of the
$data
returned by the video providersHere is enhanced verison of brasofilo plugin:
Do not remember to clean oembed cache! You can use this SQL command to do that:
More info at https://siteorigin.com/clearing-oembed-cache/
This is a good method…but a less involved one (for those of us less experienced) would be to use this tutorial.
Do not plug in the YouTube embed code as YT(YouTube) gives it (you can try, but it will be ganky)…instead just replace the source from the embed code of your vid UP TO
&autoplay=1
(leave this on the end as it is).eg.
original code YT gives:
Code used in tutorial with same YT src:
Other than that, just replace the img source and path with your own, and voilà !
Try this code. Just copy and paste in a HTML file.