From: Alexander Ebert Date: Sun, 12 Apr 2015 12:49:08 +0000 (+0200) Subject: Work-around for Firefox returning bogus values for image dimensions X-Git-Tag: 2.1.3~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bcc5af2bfb556b693838a8a61f78549bd3a9946a;p=GitHub%2FWoltLab%2FWCF.git Work-around for Firefox returning bogus values for image dimensions --- diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 42b72a0ac8..38e72bc292 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -738,13 +738,23 @@ $.widget('ui.wcfImageViewer', { } if (this.options.staticViewer && !imageData.image.height && $image[0].complete) { - $image.css({ - height: 'auto', - width: 'auto' - }); - - imageData.image.height = $image[0].height; - imageData.image.width = $image[0].width; + // Firefox returns bogus values if attempting to read the real dimensions + if ($.browser.mozilla) { + var $img = new Image(); + $img.src = imageData.image.url; + + imageData.image.height = $img.height; + imageData.image.width = $img.width; + } + else { + $image.css({ + height: 'auto', + width: 'auto' + }); + + imageData.image.height = $image[0].height; + imageData.image.width = $image[0].width; + } } var $height = imageData.image.height; @@ -766,7 +776,6 @@ $.widget('ui.wcfImageViewer', { } var $left = Math.floor((containerDimensions.width - $width) / 2); - this._ui.images[targetIndex].css({ height: $height + 'px', left: ($left + 10) + 'px',