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:
commit
3180f456d2
|
@ -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
Loading…
Reference in New Issue