mediawiki.special.upload: Don't fail when trying to thumbnail invalid file
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 14 Apr 2016 21:16:22 +0000 (23:16 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 14 Apr 2016 21:22:58 +0000 (21:22 +0000)
The thumbnail spinner would spin forever if we never got a 'load' event
on the image.

Bug: T132242
Change-Id: I1c68ed185b58950c3648f56e07144bb29a8bed56

resources/src/mediawiki.special/mediawiki.special.upload.js

index 6bbe32d..377b1f7 100644 (file)
 
                                        $( '#mw-upload-thumbnail .fileinfo' ).text( info );
                                };
+                               img.onerror = function () {
+                                       // Can happen for example for invalid SVG files
+                                       clearPreview();
+                               };
                                img.src = dataURL;
                        }, mw.config.get( 'wgFileCanRotate' ) ? function ( data ) {
                                try {