test
parent
30175b02e3
commit
b9e436209a
|
@ -1124,14 +1124,30 @@ class VariantSelects extends HTMLElement {
|
|||
|
||||
const mediaGalleries = document.querySelectorAll(`[id^="MediaGallery-${this.dataset.section}"]`);
|
||||
mediaGalleries.forEach((mediaGallery) => {
|
||||
mediaGallery.setActiveMedia(`${this.dataset.section}-${this.currentVariant.featured_media.id}`, true);
|
||||
//mediaGallery.setActiveMedia(`${this.dataset.section}-${this.currentVariant.featured_media.id}`, true);
|
||||
|
||||
// how to get second image id from the gallery
|
||||
console.log('mediaGallery', mediaGallery);
|
||||
|
||||
// get the second image id
|
||||
const secondImageId = mediaGallery.querySelector('.thumbnail-list__item:nth-child(2)').dataset;
|
||||
console.log('secondImageId', secondImageId);
|
||||
const galleryImages = mediaGallery.querySelectorAll('.thumbnail-list__item:nth-child(2)').dataset;
|
||||
|
||||
for (const galleryImage of galleryImages) {
|
||||
// if display is not none, then show the image
|
||||
if (galleryImage.style.display !== 'none') {
|
||||
|
||||
|
||||
|
||||
const target = galleryImage.target; // "template--22806669590804__main-38794319626516"
|
||||
const targetId = target.split('__')[1]; // "main-38794319626516"
|
||||
const targetIdSplit = targetId.split('-')[1]; // "38794319626516"
|
||||
|
||||
mediaGallery.setActiveMedia(`${this.dataset.section}-${targetIdSplit}`, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue