Force height for the gallery if the image is no loaded at time of init

This commit is contained in:
Mike Jolley 2017-06-30 15:58:55 +01:00
parent c7e4be8f34
commit d78f088ba2
2 changed files with 21 additions and 1 deletions

View File

@ -144,6 +144,26 @@ jQuery( function( $ ) {
$target.css( 'opacity', 1 );
}
} );
// 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