GET IN TOUCH
Want to get more information and discuss commercial opportunities?
document.addEventListener('DOMContentLoaded', function() {
function naturalSort(a, b) {
const aTitle = a.querySelector('a').getAttribute('title');
const bTitle = b.querySelector('a').getAttribute('title');
return aTitle.localeCompare(bTitle, undefined, {
numeric: true,
sensitivity: 'base'
});
}
const galleryContainer = document.querySelector('.et_pb_gallery_items');
if (galleryContainer) {
const galleryItems = Array.from(galleryContainer.querySelectorAll('.et_pb_gallery_item'));
// Sort items
galleryItems.sort(naturalSort);
// Re-append and update classes
galleryItems.forEach((item, index) => {
galleryContainer.appendChild(item);
// Update the item index class
item.className = item.className.replace(/et_pb_gallery_item_0_d+/, `et_pb_gallery_item_0_${index}`);
// Update first_in_row and last_in_row classes (assuming 4 per row)
item.classList.remove('first_in_row', 'last_in_row');
if (index % 4 === 0) item.classList.add('first_in_row');
if (index % 4 === 3) item.classList.add('last_in_row');
});
console.log('Gallery sorted naturally!');
}
});
