How to download YouTube video thumbnails using PHP

The following post shows how you can retrieve any YouTube video thumbnails in PHP without using the YouTube api. I needed this for a onetime solution to get some thumbnails for a few videos and using the api seemed a little time consuming. So here goes.

YouTube video thumbnail structure

The urls from where you can get the thumbnails are shown below. Each video generates around 4 standard thumbnails. The first image is a full size image while others are smaller thumbnail images. You can easily try the following urls in the browser by replacing the ‘youtube-video-id’ part with the corresponding videos id.

# Default thumbnail

The id is the last part of the YouTube url or the id in the ‘v’ GET variable.

# Example, the id here is 'VSB4wGIdDwo'

Other than the above mentioned urls there are a few specific ones listed below which are also available.

Standard quality version:

Medium quality version:

High quality version:

Maximum quality version:

Note: Not all image types may be available for a video.

Getting images using PHP

Below is the PHP code to download thumbnails when given the video id.

2 thoughts to “How to download YouTube video thumbnails using PHP”

  1. Thanks for the tip: nice to be able to get those images.

    If you know the URL you can use $image = file_get_contents($youtube_thumb_url); instead of CURL.

    If the URL is not valid/reachable, PHP issues a warning and $image is bool(false).

Comments are closed.