Home > php教程 > php手册 > 显示youtube视频缩略图和Vimeo视频缩略图代码分享

显示youtube视频缩略图和Vimeo视频缩略图代码分享

WBOY
Release: 2016-06-06 20:24:55
Original
1644 people have browsed it

这篇文章主要介绍了显示youtube视频缩略图和Vimeo视频缩略图的代码,需要的朋友可以参考下

复制代码 代码如下:


function video_image($url){
   $image_url = parse_url($url);
     if($image_url['host'] == 'www.youtube.com' ||
        $image_url['host'] == 'youtube.com'){
         $array = explode("&", $image_url['query']);
         return "http://img.youtube.com/vi/".substr($array[0], 2)."/0.jpg";
     }else if($image_url['host'] == 'www.youtu.be' ||
              $image_url['host'] == 'youtu.be'){
         $array = explode("/", $image_url['path']);
         return "http://img.youtube.com/vi/".$array[1]."/0.jpg";
     }else if($image_url['host'] == 'www.vimeo.com' ||
         $image_url['host'] == 'vimeo.com'){
         $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".
         substr($image_url['path'], 1).".php"));
         return $hash[0]["thumbnail_medium"];
     }
}

显示youtube视频缩略图和Vimeo视频缩略图代码分享

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template