dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.63k stars 356 forks source link

Retina Bug #90

Closed david-nguyen closed 8 years ago

david-nguyen commented 8 years ago

I'm pretty sure there is a bug with the retina, because you are calling handleSource to set the src, it calls the original dataSrc and not the split version.

DKudleichuk commented 8 years ago

I confirm this bug too, please fix it asap

Mirull commented 8 years ago

+1 (used v.1.6.1)

DKudleichuk commented 8 years ago

i believe it is related to this message from changelog:

Marked breakpoints as obsolete. Will be removed in upcoming version. Use srcset and/or the picture element instead.

p.s. here is a hotfix of problem (if you can't replace src with srcset immediately):

function handleSource(ele, attr, dataAttr) {
        var dataSrc = ele.getAttribute(dataAttr);

        if (dataSrc) {

                var dataSrcSplitted = dataSrc.split('|');
                var dataSrc = dataSrcSplitted[isRetina && dataSrcSplitted.length > 1 ? 1 : 0];

            ele[attr] = dataSrc;
            ele.removeAttribute(dataAttr);
        }
    }
david-nguyen commented 8 years ago

Thanks for the code, I took a look I think this is what the author is referring to for breakpoints

// Example
var bLazy = new Blazy({ 
    breakpoints: [{
          width: 420 // max-width
    , src: 'data-src-small'
     }
       , {
          width: 768 // max-width
        , src: 'data-src-medium'
}]
});
dinbror commented 8 years ago

Hey guys.

You're right. I'll fix it when I'm home from the Beach tomorrow. You can use 1.5.x or @WPJobs's hotfix until

dinbror commented 8 years ago

Back from the beach :) Fixed in v. 1.6.2