2014-12-05 59 views

回答

0

只需調用與所需的格式<img>元素,例如php:

$id = "ATYklyGZU4I"; 
echo "<img src=http://img.youtube.com/vi/$id/1.jpg>"; 

其他格式在您的鏈接中提到。

0

嘗試使用此代碼,它會給你視頻圖像的網址。

$url = "http://www.youtube.com/embed/ATYklyGZU4I?feature=oembed"; 
echo getYouTubeVideoImage($url); 

function getYouTubeVideoImage($youtube_code){ 
    preg_match('/youtube\.com\/v\/([\w\-]+)/', $youtube_code, $match); 


    if(!isset($match[1]) || $match[1] == ''){ 
     preg_match('/youtube\.com\/embed\/([\w\-]+)/', $youtube_code, $match); 
    } 
    if(!isset($match[1]) || $match[1] == ''){ 
     preg_match('/v\=(.+)&/',$youtube_code ,$match); 
    } 

    $full_size_thumbnail_image = "http://img.youtube.com/vi/".$match[1]."/0.jpg"; 
    $small_thumbnail_image1 = "http://img.youtube.com/vi/".$match[1]."/1.jpg"; 
    $small_thumbnail_image2 = "http://img.youtube.com/vi/".$match[1]."/2.jpg"; 
    $small_thumbnail_image3 = "http://img.youtube.com/vi/".$match[1]."/3.jpg"; 

    // return whichever thumbnail image you would like to retrieve 
    return $full_size_thumbnail_image;  
}