Merge "Fix gallery rearrange on resize with missing images"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 10 Jan 2015 20:01:21 +0000 (20:01 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 10 Jan 2015 20:01:21 +0000 (20:01 +0000)
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 );
                                }
                        } );
                } ) );