diff --git a/plugins/video-embed/ls.video-embed.js b/plugins/video-embed/ls.video-embed.js index 52c8aa96..fdab5d0d 100644 --- a/plugins/video-embed/ls.video-embed.js +++ b/plugins/video-embed/ls.video-embed.js @@ -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'; @@ -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); }