Skip to content

Commit

Permalink
Make yt thumb size configurable (see aFarkas#681)
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed Aug 4, 2019
1 parent 74148f7 commit 107be77
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/video-embed/ls.video-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
;
var idIndex = Date.now();
var regId = /\{\{id}}/;
var regYtImg = /\{\{hqdefault}}/;
var regAmp = /^&/;
var youtubeImg = protocol + '//img.youtube.com/vi/{{id}}/hqdefault.jpg';
var youtubeImg = protocol + '//img.youtube.com/vi/{{id}}/{{hqdefault}}.jpg';
var youtubeIframe = protocol + '//www.youtube.com/embed/{{id}}?autoplay=1';
var vimeoApi = protocol + '//vimeo.com/api/oembed.json?url=https%3A//vimeo.com/{{id}}';
var vimeoIframe = protocol + '//player.vimeo.com/video/{{id}}?autoplay=1';
Expand Down Expand Up @@ -77,7 +78,9 @@
}

function embedYoutubeImg(id, elem){
elem.style.backgroundImage = 'url('+ youtubeImg.replace(regId, id) +')';
var ytImg = elem.getAttribute('data-thumb-size') || lazySizes.cfg.ytThumb || 'hqdefault';

elem.style.backgroundImage = 'url('+ youtubeImg.replace(regId, id).replace(regYtImg, ytImg) +')';
elem.addEventListener('click', embedYoutubeIframe);
}

Expand Down

0 comments on commit 107be77

Please sign in to comment.