If I have a YouTube video URL, is there a way to get the associated thumbnail from the YouTube API using PHP and cURL?
Solution:
Each YouTube video has four generated images. They have the following format:
https://img.youtube.com/vi//0.jpg
https://img.youtube.com/vi//1.jpg
https://img.youtube.com/vi//2.jpg
https://img.youtube.com /vi//3.jpg
The first in the list is the full size image, the others are thumbnail images. Default The thumbnail image (i.e. one of 1.jpg, 2.jpg, 3.jpg) is:
https://img.youtube.com/vi/ /default.jpg
For a high-quality version of the thumbnail, use a URL similar to this:
https://img.youtube.com/vi//hqdefault.jpg
There is also a medium quality version of the thumbnail, using a URL similar to HQ:
https://img.youtube.com/vi//mqdefault.jpg
For the standard definition version of the thumbnail, use a URL similar to this:
https://img.youtube.com/vi//sddefault.jpg
For the maximum resolution version of the thumbnail, use a URL similar to this:
https://img.youtube.com/vi//maxresdefault.jpg
All the above URLs are also available via HTTP. Also, the slightly shorter hostname i3.ytimg.com replaces the above img.youtube.com.
Alternatively, you can use the YouTube Data API (v3) to get the thumbnail image.