work-around for Chrome on iOS
authorAlexander Ebert <ebert@woltlab.com>
Sat, 29 Nov 2014 19:29:22 +0000 (20:29 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 29 Nov 2014 19:29:22 +0000 (20:29 +0100)
wcfsetup/install/files/js/WCF.ImageViewer.js

index fef0f6a7ac6505131b9bf00acbd4fbba23a9f5d7..040e12f73d2301b57654d5178d765ec2a73d97bf 100644 (file)
@@ -714,10 +714,23 @@ $.widget('ui.wcfImageViewer', {
                        $image.trigger('load');
                }
                
-               if (this.options.staticViewer && !imageData.height && $image[0].complete) {
+               if (this.options.staticViewer && !imageData.image.height && $image[0].complete) {
                        var $img = new Image();
                        $img.src = imageData.image.url;
                        
+                       // Chrome on iOS seems to not fetch images from cache
+                       if (navigator.userAgent.match(/CriOS/)) {
+                               var self = this;
+                               $img.onload = function() {
+                                       imageData.image.height = this.height;
+                                       imageData.image.width = this.width;
+                                       
+                                       self._renderImage(targetIndex, imageData, containerDimensions);
+                               };
+                               
+                               return;
+                       }
+                       
                        imageData.image.height = $img.height;
                        imageData.image.width = $img.width;
                }