Add image resolution to title url

This commit is contained in:
Alexander Popov 2017-10-29 01:06:47 +03:00
parent 96ad2a323a
commit 568caa4434

10
ytcg.js
View File

@ -1,7 +1,13 @@
function getCover() function getCover()
{ {
var videoUrl = document.getElementById('videoUrl').value; var videoUrl = document.getElementById('videoUrl').value;
var coverUrl = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg'; var videoCover = new Image();
videoCover.onload = function()
{
document.getElementById('ytImage').innerHTML = document.getElementById('ytImage').innerHTML =
'<a download href="' + coverUrl + '"><img src="'+ coverUrl +'"></a>'; '<a title="' + videoCover.width + 'x' + videoCover.height + '" download href="' + videoCover.src + '"><img src="'+ videoCover.src +'"></a>';
}
videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg';
} }