Sometime it’s necessary to display the Thumbnail Image of a youtube video from URL. So in this tutorial am going to example you how to get the thumbnail image of a video from youtube. Here am using PHP to obtain the output.
![]()
To fetch the video thumbnail image from Youtube, first we need the get the video id from given URL.
Now we can explode the youtube URL and get the video ID (In this case 5wqbC3_ZOQg) using php.
//explode the url to get video id and save the id to a variable
$fetch=explode("v=", $url);
$videoid=$fetch[1];
Now pass this video id to the img src tag
//Display the image
//Display 1st thumbnail
echo '<img src="http://img.youtube.com/vi/'.$videoid.'/1.jpg" width="100" height="90" />';
This will display you the first thumbnail image. if you want to use second or third image just change the number in image src tag.
//Display 1st thumbnail
echo '<img src="http://img.youtube.com/vi/'.$videoid.'/2.jpg" width="100" height="90" />';
Hope that you like this article if so please share the article. If you want you can download the example file above. Thank You !
