From 568caa4434205b8378f60bc1f11977e20445f05a Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sun, 29 Oct 2017 01:06:47 +0300 Subject: [PATCH] Add image resolution to title url --- ytcg.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ytcg.js b/ytcg.js index 6890c9f..5078bb4 100644 --- a/ytcg.js +++ b/ytcg.js @@ -1,7 +1,13 @@ function getCover() { var videoUrl = document.getElementById('videoUrl').value; - var coverUrl = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg'; - document.getElementById('ytImage').innerHTML = - ''; + var videoCover = new Image(); + + videoCover.onload = function() + { + document.getElementById('ytImage').innerHTML = + ''; + } + + videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg'; }