From 37f0ccd95c55814b0ef26685a0318bbd51b2280e Mon Sep 17 00:00:00 2001 From: Michael Weichert Date: Thu, 6 Oct 2011 10:46:36 -0400 Subject: [PATCH] Fixed 'could not extract height/width of image' issue, if the image is taking longer than 2 seconds to download --- src/galleria.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/galleria.js b/src/galleria.js index ef452cdf..6b49a582 100644 --- a/src/galleria.js +++ b/src/galleria.js @@ -4788,19 +4788,17 @@ Galleria.Picture.prototype = { // Delay the callback to "fix" the Adblock Bug // http://code.google.com/p/adblockforchrome/issues/detail?id=3701 if ( ( !this.width || !this.height ) ) { - window.setTimeout( (function( img ) { - return function() { - if ( img.width && img.height ) { - complete.call( img ); - } else { - Galleria.raise('Could not extract width/height from image: ' + img.src + - '. Traced measures: width:' + img.width + 'px, height: ' + img.height + 'px.'); - } - }; - }( this )), 2); - } else { - complete.call( this ); - } + $(this).load(function(response, status){ + if (status == 'error') { + Galleria.raise('Could not extract width/height from image: ' + img.src + + '. Traced measures: width:' + img.width + 'px, height: ' + img.height + 'px.'); + } + else complete.call(this); + }); + } + else { + complete.call(this); + } }; }( this, callback, src ));