Asked 7 years ago
4 Jan 2017
Views 988

posted

YouTube video thumbnail by YouTube API

how to get YouTube video thumbnail by YouTube API ? by calling web api through CURL and PHP ,is it possible to get YouTube video thumbnail ?
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

Do not need cUrl or web api to get YouTube video thumbnail .
because it can be easily get by its Video id


https://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg
// High quality image - high quality thumbnail 
https://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
// Medium Quality image - medium quality thumbnail 
https://img.youtube.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
// Standard  Quality image - thumbnail 
https://img.youtube.com/vi/<insert-youtube-video-id-here>/sddefault.jpg

PHP code to get YouTube video thumbnail image

$youtube_url="https://www.youtube.com/watch?v=952ACYyWgc4";
$data=explode("?v=",$youtube_url);
$image_url="https://img.youtube.com/vi/".$data[1]."/sddefault.jpg";
//short image $image_url="https://i3.ytimg.com/vi/".$data[1]."/sddefault.jpg";
echo "<img src='".$image_url."' />";

using direct image from img.youtube.com , is that generic . i mean there should be some good way to do it officially by web api - Rasi  
Jan 6 '17 04:42
Post Answer