Skip to main content
Print

To show full Image thumbnail for the gallery module Script code



// 	to show original image thumbnails for the gallery
document.addEventListener('DOMContentLoaded', function() {
  // Select all images inside Divi Gallery grid
  document.querySelectorAll('.et_pb_gallery .et_pb_gallery_image img').forEach(function(img) {
    // Get the parent anchor link, which has the full image URL
    var fullImgUrl = img.closest('a').getAttribute('href');
    if (fullImgUrl) {
      img.setAttribute('src', fullImgUrl); // Swap to full-res
      img.removeAttribute('srcset');       // Prevent browser using srcset
      img.removeAttribute('sizes');        // Remove responsive sizes
      img.style.width = '100%';            // Make sure it fills the container
      img.style.height = 'auto';
      img.style.objectFit = 'cover';       // Keep crop
      img.style.maxWidth = 'none';         // Prevent Divi from limiting width
    }
  });
});


Table of Contents