Fix gallery rearrange on resize with missing images
authorm4tx <m4tx@m4tx.pl>
Fri, 9 Jan 2015 21:59:51 +0000 (22:59 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 10 Jan 2015 19:55:05 +0000 (19:55 +0000)
Follow-ups I286e0a4c8230c11619ca30f8f3b66778de835a33

Bug: T55664
Change-Id: I95cc64de11df3197378f4873d62a76333d55b452

resources/src/mediawiki.page/mediawiki.page.gallery.js

index e3ffbda..e4cd3a2 100644 (file)
                                        imgHeight = $( this ).data( 'imgHeight' ),
                                        width = $( this ).data( 'width' ),
                                        captionWidth = $( this ).data( 'captionWidth' ),
+                                       $innerDiv = $( this ).children( 'div' ).first(),
+                                       $imageDiv = $innerDiv.children( 'div.thumb' ),
                                        $imageElm, imageElm;
 
                                // Restore original sizes so we can arrange the elements as on freshly loaded page
                                $( this ).width( width );
-                               $( this ).children( 'div' ).first().width( width );
-                               $( this ).children( 'div' ).first().children( 'div.thumb' ).width( imgWidth );
+                               $innerDiv.width( width );
+                               $imageDiv.width( imgWidth );
                                $( this ).find( 'div.gallerytextwrapper' ).width( captionWidth );
 
                                $imageElm = $( this ).find( 'img' ).first();
                                if ( imageElm ) {
                                        imageElm.width = imgWidth;
                                        imageElm.height = imgHeight;
+                               } else {
+                                       $imageDiv.height( imgHeight );
                                }
                        } );
                } ) );