YouTube Thumbnail Downloader
YouTube Thumbnail Downloader
Paste a YouTube video link below to download its thumbnail.
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #ff9a9e, #fad0c4);
color: #333;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
overflow: hidden;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
text-align: center;
max-width: 400px;
width: 90%;
}
.title {
color: #ff6f61;
font-size: 24px;
margin-bottom: 10px;
}
.subtitle {
color: #555;
font-size: 14px;
margin-bottom: 20px;
}
form {
display: flex;
flex-direction: column;
}
input[type="text"] {
padding: 10px;
border: 2px solid #ff6f61;
border-radius: 4px;
margin-bottom: 10px;
font-size: 14px;
}
button {
padding: 10px;
background-color: #ff6f61;
color: #fff;
border: none;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #e65c54;
}
.result {
margin-top: 20px;
display: none;
flex-direction: column;
align-items: center;
}
.result-title {
font-size: 16px;
margin-bottom: 10px;
}
#thumbnailImage {
max-width: 100%;
border: 2px solid #ff6f61;
border-radius: 4px;
margin-bottom: 10px;
}
.download-btn {
display: inline-block;
padding: 10px;
background-color: #ff6f61;
color: #fff;
text-decoration: none;
border-radius: 4px;
transition: background-color 0.3s;
}
.download-btn:hover {
background-color: #e65c54;
}
document.getElementById('thumbnailForm').addEventListener('submit', function (event) {
event.preventDefault();
const videoUrl = document.getElementById('videoUrl').value.trim();
const videoId = extractVideoId(videoUrl);
if (!videoId) {
alert('Please enter a valid YouTube URL.');
return;
}
const thumbnailUrl = `https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`;
// Display thumbnail
const thumbnailImage = document.getElementById('thumbnailImage');
const downloadLink = document.getElementById('downloadLink');
const resultSection = document.getElementById('thumbnailResult');
thumbnailImage.src = thumbnailUrl;
thumbnailImage.alt = 'Thumbnail Preview';
downloadLink.href = thumbnailUrl;
resultSection.style.display = 'flex';
});
function extractVideoId(url) {
const regex = /(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^&\s]{11})|youtu\.be\/([^&\s]{11})/;
const match = url.match(regex);
return match ? (match[1] || match[2]) : null;
}