22 lines
623 B
JavaScript
22 lines
623 B
JavaScript
|
function getCover()
|
||
|
{
|
||
|
'use strict';
|
||
|
|
||
|
let videoUrl = document.getElementById('videoUrl').value;
|
||
|
let imageDiv = document.getElementById('ytImage');
|
||
|
imageDiv.innerHTML = '';
|
||
|
|
||
|
let videoCover = document.createElement('img');
|
||
|
let imageLink = document.createElement('a');
|
||
|
|
||
|
videoCover.src = 'https://img.youtube.com/vi/' + YouTubeGetID(videoUrl) + '/maxresdefault.jpg';
|
||
|
imageLink.href = videoCover.src;
|
||
|
imageLink.download = 'cover';
|
||
|
videoCover.onload = function() {
|
||
|
imageLink.title = videoCover.width + 'x' + videoCover.height;
|
||
|
}
|
||
|
|
||
|
imageLink.appendChild(videoCover);
|
||
|
imageDiv.appendChild(imageLink);
|
||
|
}
|