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; i = elems.length;
while ( i-- ) { while ( i-- ) {
elem = elems[i]; elem = elems[i];
if ( if ( elem.naturalWidth !== 0 && elem.naturalHeight !== 0 ) {
typeof elem.naturalWidth !== 'number' || continue;
elem.naturalWidth === 0 || }
typeof elem.naturalHeight !== 'number' || if ( window.getComputedStyle(elem).getPropertyValue('display') === 'none' ) {
elem.naturalHeight === 0 continue;
) { }
src = elem.getAttribute('src') || ''; src = elem.getAttribute('src');
if ( src ) {
elem.removeAttribute('src'); elem.removeAttribute('src');
elem.setAttribute('src', src); elem.setAttribute('src', src);
} }

View File

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