From 7ca24a99c25a5b068f87f55b36044242c3207398 Mon Sep 17 00:00:00 2001 From: David Hellsing Date: Wed, 3 Aug 2011 21:55:34 +0200 Subject: [PATCH] fixed adblock bug #3701 --- src/galleria.js | 60 +++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/galleria.js b/src/galleria.js index 7148accb..d2e254c5 100644 --- a/src/galleria.js +++ b/src/galleria.js @@ -4699,40 +4699,42 @@ Galleria.Picture.prototype = { return function() { - // force chrome to reload the image in case of cache bug - // one time is enough, with a timeout - if ( ( !this.width || !this.height ) ) { - if ( !reload ) { - reload = true; - window.setTimeout((function(image, src) { - return function() { - image.attr('src', src + '?' + Utils.timestamp() ); - }; - }( $(this), src )), 50); - } else { - Galleria.raise('Could not extract width/height from image: ' + src + - '. Traced measures: width:' + this.width + 'px, height: ' + this.height + 'px.'); - } - return; - } + var complete = function() { - // save the original size - self.original = { - height: this.height, - width: this.width - }; + // save the original size + self.original = { + height: this.height, + width: this.width + }; - self.cache[ src ] = src; // will override old cache + self.cache[ src ] = src; // will override old cache - // clear the debug timeout - window.clearTimeout( self.tid ); + // clear the debug timeout + window.clearTimeout( self.tid ); - if (typeof callback == 'function' ) { - window.setTimeout(function() { - callback.call( self, self ); - },1); - } + if (typeof callback == 'function' ) { + window.setTimeout(function() { + callback.call( self, self ); + },1); + } + }; + // 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, callback, src ));