2

I have a website where i want users to post the link to videos(from youtube and vimeo) and render a thumbnail related to the link typed in above. I want to generate iframe embed when typed a link

I am using php

Any help on how this can be done?

zerocool
  • 316
  • 1
  • 4
  • 19
  • This question is already answered here: http://stackoverflow.com/questions/2068344/how-to-get-thumbnail-of-youtube-video-link-using-youtube-api – gurisko Jul 25 '13 at 21:09
  • Thank you sir I want to generate iframe embed when typed a link – zerocool Jul 25 '13 at 21:19

3 Answers3

0

Simple, just get the ID of the video from YouTube and the sequence number of the image you want and plug them into [VIDEOID] AND [SEQNUM] respectively in the following URL:

http://img.youtube.com/vi/[VIDEOID]/[SEQNUM].jpg

So for example for this URL:

http://www.youtube.com/watch?v=dOwZZyGJ9aQ

the thumbnails can be acquired by going to:

http://img.youtube.com/vi/dOwZZyGJ9aQ/0.jpg

http://img.youtube.com/vi/dOwZZyGJ9aQ/1.jpg

http://img.youtube.com/vi/dOwZZyGJ9aQ/2.jpg

http://img.youtube.com/vi/dOwZZyGJ9aQ/3.jpg

and so on..

Source: http://www.tonylea.com/2011/how-to-get-youtube-thumbnail-images/

Anshul
  • 1,302
  • 3
  • 15
  • 36
0

Both of youtube and vimeo have meta information tags itemprop="thumbnailUrl" in their DOM.

for example: for youtube it is

<link itemprop="thumbnailUrl" href="http://i1.ytimg.com/vi/CElN2XzquGM/hqdefault.jpg">

for vimeo it is

<meta itemprop="thumbnailUrl" content="http://b.vimeocdn.com/ts/435/519/435519601_1280.jpg">

I guess other video hostings may have this kind of meta information, and this is where facebook gets images from

Armen
  • 287
  • 1
  • 8
0

In YouTube Data API v3, you can get video's thumbnails with videos->list function.

From snippet.thumbnails.(key), you can pick the default, medium or high resolution thumbnail, and get it's width, height and URL.

You can also update thumbnails with thumbnails->set functionality.

For examples, you can check out YouTube API Samples project. (PHP ones)

Ibrahim Ulukaya
  • 12,767
  • 1
  • 33
  • 36