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?
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?
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/
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
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)