PHP

Each YouTube video has 4 generated images. They are predictably formatted as follows:

  1. http://img.youtube.com/vi//0.jpg
  2. http://img.youtube.com/vi//1.jpg
  3. http://img.youtube.com/vi//2.jpg
  4. http://img.youtube.com/vi//3.jpg


The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is:

  • http://img.youtube.com/vi//default.jpg

For the high quality version of the thumbnail use a url similar to this:

  • http://img.youtube.com/vi//hqdefault.jpg

There is also a medium quality version of the thumbnail, using a url similar to the HQ:

  • http://img.youtube.com/vi//mqdefault.jpg

For the maximum resolution version of the thumbnail use a url similar to this:

  • http://img.youtube.com/vi//maxresdefault.jpg

All of the above urls are available over https too. Just change http to https in any of the above urls.

Alternatively, you can use the YouTube API to get thumbnail images.

Other ways to get Youtube thumbnail:

YouTube Thumbnail Generator is one of the first Thumbnail Generators that automatically grabs YouTube generated thumbnails from videos.

 

API

The URL trick is undocumented, therefore, unreliable. You can use YouTube Data API to retrieve video thumbnails, caption, description, rating, statistics and more. Trying out the API takes 30 seconds or less:

What does the data returned by the API look like
Open these URLs in your browser to find out:

  • http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&prettyprint=true
  • http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&prettyprint=true&alt=json
  • http://gdata.youtube.com/feeds/api/videos/gzDS-Kfd5XQ?v=2&prettyprint=true&alt=jsonc

Notes:

  1. gzDS-Kfd5XQ is the Id of the video.
  2. 3-rd one because it has the smallest footprint
0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

19 + 13 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.

You May Also Like

301 .htaccess Redirect

To prevent getting 404 File Not Found error (traffic coming from links, bookmarks and search engines) when URLs and paths on site have changed, use .htaccess 301 redirect.