- You found a nice YouTube Thumbnail
- And you want to inspect it
- By checking out the HTML Source Code
This guide shows you the way.
How to find the Source Code of a YouTube Thumbnail
- Open the YouTube video with the thumbnail you’re interested in.
- Right-click anywhere on the video page and select “View Page Source”
(or press Ctrl+U on Windows/Linux or Command+U on Mac). - Search in page for “thumbnailUrl“. This will highlight the URL of the thumbnail image within the source code.
- Copy the URL and paste it into your browser to view the thumbnail directly.
Get the Thumbnail via Embed Code
Extract video ID from the embed code, then use img.youtube.com/vi/ID/hqdefault.jpg
(standard).
You can also use /maxresdefault.jpg
at the end of the URL to get the thumbnail in full size.
1. Copy the video’s ID
- Parse the embed code: Locate the
src
attribute within theiframe
tag. It contains the video URL. - Extract the video ID: Copy the part of the URL between “watch?v=” and the next “&” or the end of the URL.
This 11-character string is the video ID.
2. Add it in this URL
- Standard definition: Use this format:
https://img.youtube.com/vi/VIDEO_ID/hqdefault.jpg
- High resolution (if available): Use:
https://img.youtube.com/vi/VIDEO_ID/maxresdefault.jpg
- Replace “VIDEO_ID” with the actual video ID you extracted.
3. JavaScript
For dynamic extraction on a website:
function getYouTubeThumbnail(embedCode) {
const videoId = embedCode.match(/watch\?v=(.*?)(&|$)/)[1];
return `https://img.youtube.com/vi/${videoID}/hqdefault.jpg`;
}
const thumbnailUrl = getYouTubeThumbnail(embedCode);
// Use the thumbnailUrl as needed
If the embed code is unavailable, use the video URL directly to get the thumbnail.
Important Note
Keep in mind that YouTube’s HTML structure can change,Β so these methods might not always forever. At one point, they might need adjustments.
Also, be sure to:
- Respect copyright laws when using images you find online.
- Only use thumbnails for fair use purposes or with the creator’s permission.
Conclusion
That’s right about it. All you need to know!
Thank you for reading this,
Thumbnail Test