How do I get a YouTube video thumbnail from YouTube using PHP

Have you ever been on youtube and admired a thumbnail of a video?

If your answer is YES, then in this simple post I will teach and share with you the source code of a PHP program that extracts a thumbnail from a youtube video and see its full details in different resolutions.

For the different resolutions, you need to mind about image name/value for example: hqdefault, mqdefault, sddefault, maxresdefault and so much more as explained below.

Video Source Code

Visit my Github repo and download the source code:

Make sure you try to enhance or add value to the program than leaving it at that stage.I will always be around to help you when you are stuck.

For the high-quality version of the thumbnail use a URL similar to this:


There is also a medium quality version of the thumbnail, using a URL similar to the HQ:


For the standard definition version of the thumbnail, use a URL similar to this:


For the maximum resolution version of the thumbnail use a URL similar to this:


Each YouTube video has four generated images. They are predictably formatted as follows:


Those 4 pictures (0,1,2,3.jpg) above are found in the thumbnail section when you are uploading or editing a video on youtube.

Let me break down this for you;

  • 0.jpg - This is the custom thumbnail/picture you upload in case you don't use the auto-generated thumbnails by youtube.
  • 1.jpg - This is one of the auto-generated thumbnails by youtube when you upload a video.
  • 2.jpg - The same as image 1.
  • 3.jpg - The same as image 1.

Hope this post helped you, If so please consider becoming a subscriber on my channel Oston Code Cypher. PEACE

Related Post(s)

» Learn PHP Complete Guide - Environment Setup

» Quick Autocomplete App With PHP and JQUERY MOBILE

» Learn PHP Complete Guide - Introduction

» How to create smart Urls using PHP

» How do I get a YouTube video thumbnail from YouTube using PHP

collections_bookmark Category :: Php
date_range Published :: 2 months ago At: 12:38 AM
event_note Detailed Date :: Apr 05th, 2021
person Writer :: Code