Show the thumbnail of any youtube video as an image

Hi there! After a lot of searching and frustration believing that this was possible using youtube’s API (you can’t, unless it’s a video you’ve uploaded yourself and you’re using OAuth to access your google account), I found that this is actually very easy to solve. Here’s how you can display an image that takes as a source the thumbnail of any youtube video using its ID

You can access the thumbnail of any video with this URL:
http://img.youtube.com/vi/*YOUTUBE VIDEO ID*/0.jpg

Just indicate this URL as the source of the image, replacing it with the video ID you want

image
Here I am using Arbitrary Text to indicate the ID, but you could have an input in which to request the URL of a video, do a split and store it to use it in the image.

Just in case, the ID of a YouTube video can be entered in two ways:

Long form
https://www.youtube.com/watch?v=jNQXAC9IVRw&ab_channel=jawed

In this case, you should split the link by the “v=” characters and take the second item. Then, to remove the other parameters, do a second split dividing by the “&” character and take the first item
image

Short form
https://youtu.be/jNQXAC9IVRw

if you don’t care about additional parameters, you can just take the last value after spliting it by “/”
image

But in case someone enters additional parameters (like the time to start the video in this example https://youtu.be/jNQXAC9IVRw?t=10) a second split prevents any errors
image

Hope this is useful to you.
Bye!

9 Likes

Thanks a ton for this guide mate, saved a lot of time else i’d figuring out it with data API

2 year old solution but works like a charm!