顯示youtube視訊縮圖和Vimeo視訊縮圖程式碼分享

NO IMAGE
1 Star2 Stars3 Stars4 Stars5 Stars 給文章打分!
Loading...

複製程式碼 程式碼如下:
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”];
     }
}

<img src=”<?php echo video_image(‘youtube URL’); ?>” />

您可能感興趣的文章:

視訊下載利器 Youtube Downloader v2.4

相關文章

程式語言 最新文章