custompatchmaker

Order Custom Patches Online

// --- Dynamically fix WooCommerce gallery height --- document.addEventListener('DOMContentLoaded', function() { var galleries = document.querySelectorAll('.woocommerce-product-gallery__wrapper'); for (var g = 0; g < galleries.length; g++) { (function(gallery) { function adjustHeight() { var images = gallery.querySelectorAll('img'); var maxHeight = 0; for (var i = 0; i < images.length; i++) { var img = images[i]; if (img.complete) { if (img.naturalHeight > maxHeight) { maxHeight = img.naturalHeight; } } else { img.addEventListener('load', adjustHeight); } } gallery.style.height = maxHeight + 'px'; } adjustHeight(); window.addEventListener('resize', adjustHeight); })(galleries[g]); } });
Scroll to Top