This commit is contained in:
gorhill 2016-01-19 15:04:44 -05:00
parent bb27f33b35
commit 4bb9ef59ba
2 changed files with 13 additions and 9 deletions

View file

@ -50,13 +50,14 @@ elems = document.querySelectorAll('img');
i = elems.length;
while ( i-- ) {
elem = elems[i];
if (
typeof elem.naturalWidth !== 'number' ||
elem.naturalWidth === 0 ||
typeof elem.naturalHeight !== 'number' ||
elem.naturalHeight === 0
) {
src = elem.getAttribute('src') || '';
if ( elem.naturalWidth !== 0 && elem.naturalHeight !== 0 ) {
continue;
}
if ( window.getComputedStyle(elem).getPropertyValue('display') === 'none' ) {
continue;
}
src = elem.getAttribute('src');
if ( src ) {
elem.removeAttribute('src');
elem.setAttribute('src', src);
}

View file

@ -52,8 +52,11 @@ var mediaNotLoaded = function(elem) {
case 'video':
return elem.error !== null;
case 'img':
return elem.offsetWidth !== 0 && elem.offsetHeight !== 0 &&
(elem.naturalWidth === 0 || elem.naturalHeight === 0);
if ( elem.naturalWidth === 0 && elem.naturalHeight === 0 ) {
return window.getComputedStyle(elem)
.getPropertyValue('display') !== 'none';
}
break;
default:
break;
}