Want to know how to get a thumbnail for a YouTube video? It’s not as hard you think and am going to show you exactly how to do it. Months ago i got rolled up to a task of uploading hundreds of YouTube videos on a blog and i had no idea on how to get video thumbnails of YouTube videos until i had to look for a solution.
Am going to show you two ways you can easily get YouTube video thumbnails. The first method is usually the simplest and most effective. The second sometimes doesn’t return all the thumbnails but i recommend trying them both and choosing what works for you.
Getting a YouTube Video Thumbnail
Before we get started, i assume you already know how to get a YouTube video id. If you don’t know how to get the id of a YouTube video, the id of a YouTube video is the characters that follow the last “=” on the video url. If the video url is ‘https://www.youtube.com/watch?v=W7mPeQz1xEk’, then the video id id is ‘W7mPeQz1xEk’. This is the id we are going to use in all the examples below.
What you should know is when a video gets uploaded on YouTube, it automatically gets 4 generated images or you can call them thumbnails named 0 to 3. The code below will show you a more visual example of what am trying to point out:
http://img.youtube.com/vi/<youtube-video-id>/0.jpg http://img.youtube.com/vi/<youtube-video-id>/1.jpg http://img.youtube.com/vi/<youtube-video-id>/2.jpg http://img.youtube.com/vi/<youtube-video-id>/3.jpg
The first thumbnail on the list, the one named 0.jpg is usually the one with the highest definition of all the four. The rest are just normal thumbnails with variant pixels. If you need to extract images using the method above all you need to do is replace ‘youtube-video-id’ with the YouTube video you want to extract a thumbnail for.
The second method of getting a YouTube video thumbnail is quite similar to the first except we are going to make some variations on the names of the thumbnails. We shall instead use the format below:
http://img.youtube.com/vi/<youtube-video-id>/default.jpg http://img.youtube.com/vi/<youtube-video-id>/hqdefault.jpg http://img.youtube.com/vi/<youtube-video-id>/mqdefault.jpg http://img.youtube.com/vi/<youtube-video-id>/sddefault.jpg http://img.youtube.com/vi/<youtube-video-id>/maxresdefault.jpg
Of all the thumbnails generated above, the last one ‘maxresdefault.jpg’ holds the highest definition of a YouTube video. Just like the first example, replace the word ‘youtube-video-id’ with the id of your YouTube video. This method works too but usually doesn’t return all the 5 thumbnails hence, if one line of code doesn’t work for you then try the other lines. Am sure you should get at least three lines working or even all on a good day.
The URL addresses above can also be accessed via https. You can switch if you want but http also works just fine when getting a YouTube Video thumbnail. If you’ve always wanted to know how to get YouTube video thumbnails, the methods above should get the work done for you. Alternatively, if you can’t settle for the methods above you can try searching for YouTube thumbnail makers online.