How to get thumbnail of YouTube video link using YouTube API?

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

Up vote 74 down vote favorite 58 share g+ share fb share tw.

Php youtube youtube-api link|improve this question edited Feb 6 '11 at 1:38Lipis1,09151534 asked Jan 14 '10 at 23:34Ryan1,52711140 81% accept rate.

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

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:

For the high quality version of the thumbnail use a url similar to this:
For the maximum resolution version of the thumbnail use a url similar to this:
Alternatively, you can use the YouTube API to get thumbnail images.

– trusktr Mar 7 '11 at 10:14 3 There's also default. Jpg which returns the default thumbnail (one of 1. Jpg 2.

Jpg 3. Jpg). – Thai May 30 '11 at 15:23 4 To add onto that, there's also now an hqdefault.

Jpg, for the HQ version of the thumb – Mitch Grande Aug 15 '11 at 14:59.

The URL trick is undocumented therefore unreliable. Better, use read-only feeds from YouTube Data API to retrieve video thumbnails, caption, description, rating, statistics and more via AJAX: Raw JSON gdata.youtube.com/feeds/api/videos/gzDS-... Client Side Scripting Example Server Side Scripting Example data->thumbnail->sqDefault . '">'; More details here: Retrieve Title, Description and Thumbnail of a YouTube Video Using AJAX.

You can get the Video Entry which contains the URL to the video's thumbnail. There's example code in the link. Or, if you want to parse XML, there's information here.

The XML returned has a media:thumbnail element, which contains the thumbnail's URL.

I'm unable to get it out using simpleXML. It's quite hard! – aditya menon May 8 '11 at 6:18.

If you want the biggest image from youtube for specific video ID, then the code should be something like this.

Using the API will pick up the default thumb simple codes should be something like this //grab the default thumb $attrs = $media->group->thumbnail1->attributes(); $thumbnail = $attrs'url'; $thumbnail = substr($thumbnail, 0,-5); $thumb1 = $thumbnail. "default.

Jpg"; //grab the third $thumb2 = $thumbnail. "2. Jpg"; //grab the fourth.

$thumb3 = $thumbnail. "3. Jpg"; //Using simple cURL to save it your server.

You can extends the cURL below if you want it fancy just like the rest of the folks here. $ch = curl_init ("$thumb1"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec ($ch); curl_close ($ch); //using fwrite to save the above $fp = fopen("SomeLocationInreferenceToYourScript/AnyNameYouWant. Jpg",'w'); //write the file fwrite($fp, $rawdata); //and then close it.

Fclose($fp).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions