How to Get Thumbnail Images of Youtube Videos

Each Youtube video has 4 images attached to it. There is one large image 480×360 pixels and 3 others in thumbnail size – 120×90 pixels. If you want to use these images in an script or your website, there are 2 ways to do that. One is documented and the other is undocumented. The documented method is the official one using Google API for developers.

Following is an undocumented way to get images attached to a video:<<strong>video_id</strong>>/0.jpg<<strong>video_id</strong>>/1.jpg<<strong>video_id</strong>>/2.jpg<<strong>video_id</strong>>/3.jpg

For default thumbnail image of the video use:<video_id>/default.jpg

For medium quality and medium size use:<video_id>/mqdefault.jpg

For high quality larger version use:<video_id>/hqdefault.jpg

You can also use URLs in this format:;<strong>video_id</strong>&gt;/0.jpg (full size);<strong>video_id</strong>&gt;/1.jpg (thumbnail);<strong>video_id</strong>&gt;/2.jpg (thumbnail);<strong>video_id</strong>&gt;/3.jpg (thumbnail)

The drawback of the undocumented method is that it is unofficial and can be changed any time without notice – and break your thumbnails in the process.

The recommended way is to use Youtube Data Api. Using the API allows you to extract more data like caption, description, rating and video statistics.

Here is an example of how this can be done on the server side using JSON.

$json = json_decode(file_get_contents(";video_id&gt;=jsonc"));
/*use returned object to extract image data*/
echo '<img alt="" src="' . $json-&gt;data-&gt;thumbnail-&gt;sqDefault . '" />';
VN:F [1.9.12_1141]
Rating: 8.5/10 (4 votes cast)
VN:F [1.9.12_1141]
Rating: +1 (from 1 vote)
How to Get Thumbnail Images of Youtube Videos, 8.5 out of 10 based on 4 ratings
This entry was posted in Tutorials. Bookmark the permalink. Both comments and trackbacks are currently closed.