How can I get a thumbnail video for youtube and vimeo for embedding code using php?

I have a WordPress site in which I embed code to embed a video in a post editor. At the front end I need to show the Thumbnail video, clicking on them, it will show the video in the lightbox.

The requirement is that I need to show a thumbnail of the video from the video that I gave in the editor.

I will use the code for embedding YouTube and vimeo, and if this is another video, I will show a message thumbnail or a default image.

I will use one video for each post.

Thanks in advance.

+4
source share
4 answers

Using Youtube API

http://img.youtube.com/vi/VIDEO_ID/#.jpg where, VIDEO_ID = bQVoAWSP7k4 # = 1,2, or 3 

Using Vimeo API

 Making Video Request http://vimeo.com/api/v2/video/video_id.output where, video_id : The ID of the video you want information for. output : Specify the output type. It currently offer JSON, PHP, and XML formats. 

php code for vimeo:

 $imgid = 6825415; $image = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php")); echo $image[0]['thumbnail_medium']; 
+9
source

Thumbnails that you can download from the video URL.

URL VIDEO

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

URL THUMBNAIL

 http://i1.ytimg.com/vi/Xzf0rvQa4Mc/default.jpg http://i2.ytimg.com/vi/Xzf0rvQa4Mc/default.jpg http://i3.ytimg.com/vi/Xzf0rvQa4Mc/default.jpg http://i4.ytimg.com/vi/Xzf0rvQa4Mc/default.jpg 

It takes some time to replicate images to all thumbnail designs (possibly servers) for new videos.

If there is no thumbnail, it returns the image with the camera (exactly 893 bytes).

Example

  http://i4.ytimg.com/vi/Xzf0rvQa4Md/default.jpg 

if you want to get the video game id yout you like this

better with that

 regexp (youtube\.com\/(watch\?v=)?(v\/)?([\w\-]+)) 

it can handle both URLs (with /v/ and with watch?v=)

 preg_match('/youtube\.com\/v\/([\w\-]+)/', $code, $match); echo $match[3]; 
+4
source

If you want to use thumbnail in pure js / jquery no api, you can use this tool to capture a frame from video and voila!

http://video.depone.eu/

+1
source

Try Plugin , which will simplify the process of automatically displaying video thumbnails in a WordPress template.

0
source

All Articles