diff --git a/assets/global.js b/assets/global.js index b07b43e..eacbc5a 100644 --- a/assets/global.js +++ b/assets/global.js @@ -1130,15 +1130,17 @@ class VariantSelects extends HTMLElement { console.log('mediaGallery', mediaGallery); // get the second image id - const galleryImages = mediaGallery.querySelectorAll('.thumbnail-list__item:nth-child(2)').dataset; + const galleryImages = mediaGallery.querySelectorAll('.thumbnail-list__item'); + + console.log('mediaGallery.dataset', mediaGallery.dataset); for (const galleryImage of galleryImages) { // if display is not none, then show the image if (galleryImage.style.display !== 'none') { + console.log('galleryImage.dataset', galleryImage.dataset); - - const target = galleryImage.target; // "template--22806669590804__main-38794319626516" + const target = galleryImage.dataset.target; // "template--22806669590804__main-38794319626516" const targetId = target.split('__')[1]; // "main-38794319626516" const targetIdSplit = targetId.split('-')[1]; // "38794319626516"