Merge pull request #15893 from woocommerce/fix/gallery-height-with-no-cache

Force height for the gallery if the image is no loaded at time of init
This commit is contained in:
Claudio Sanches 2017-07-04 14:10:00 -03:00 committed by GitHub
commit 3180f456d2
2 changed files with 21 additions and 1 deletions

View File

@ -149,6 +149,26 @@ jQuery( function( $ ) {
gallery.initZoomForTarget( gallery.$images.eq( slider.currentSlide ) );
}
} );
// Trigger resize after main image loads to ensure correct gallery size.
$( '.woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image:eq(0) .wp-post-image' ).one( 'load', function() {
var $image = $( this );
if ( $image ) {
setTimeout( function() {
var setHeight = $image.closest( '.woocommerce-product-gallery__image' ).height();
var $viewport = $image.closest( '.flex-viewport' );
if ( setHeight && $viewport ) {
$viewport.height( setHeight );
}
}, 100 );
}
} ).each( function() {
if ( this.complete ) {
$( this ).load();
}
} );
};
/**

File diff suppressed because one or more lines are too long