aFarkas/lazysizes

iframe data-src to src not replace

onderakbulut opened this issue · 3 comments

Thank you for the plugin.
I used this on iframe but it is not replaced video link data-src to src could you help me?

I have the same problem. The script does not replace the data-src:

<iframe 
data-src="https://www.loom.com/embed/123" 
frameborder="0" 
loading="lazy" 
class="lazyload" 
webkitallowfullscreen="" 
mozallowfullscreen="" 
allowfullscreen="">
</iframe>

Images are okay, but i can't get it to work with iframes ...

Did you try iframeLoadMode: 1?

var changeIframeSrc = function(elem, src){
var loadMode = elem.getAttribute('data-load-mode') || lazySizesCfg.iframeLoadMode;
// loadMode can be also a string!
if (loadMode == 0) {
elem.contentWindow.location.replace(src);
} else if (loadMode == 1) {
elem.src = src;
}
};

rr-it commented

The iframeLoadMode: 1 is necessary for the fullscreen mode to work in Vimeo video player.
How about making this the new default?

Without fullscreen:
grafik

With fullscreen:
grafik

<script>
    window.lazySizesConfig = {
        iframeLoadMode: 1
    };
</script>
<script src="lazysizes.min.js"></script>

OR

<iframe class="lazyload" data-load-mode="1" data-src="https://player.vimeo.com/video/1084537" width="640" height="360" allowfullscreen allow="fullscreen" ></iframe>