Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello everyone 🙂
I'm working on a Shopify store and am stuck on an issue. Can anyone please help?
I want the product image to automatically change like a slider on the product page. Is there any solution for this? If you can provide the code, I would highly appreciate it.
Store URL: Foodease.ai
Password: 1234
<script>
document.addEventListener("DOMContentLoaded", function () {
let thumbnails = document.querySelectorAll(".product__thumb-item");
let mainPhoto = document.querySelector(".product__main-photos img");
let currentIndex = 0;
function changeImage() {
thumbnails.forEach(thumb => thumb.classList.remove("active"));
let currentThumb = thumbnails[currentIndex];
currentThumb.classList.add("active");
let newImagesrc=currentThumb.querySelector("img").src;
mainPhoto.src=newImageSrc;
currentIndex = (currentIndex + 1) % thumbnails.length;
}
setInterval(changeImage, 3000);
});
</script>
Then add this code before <head> https://prnt.sc/jxdXC3UhhWxf
{% style %}
.product__thumb-item.active {
border: 2px solid #ff6600;
opacity: 1;
}
.product__thumb-item img {
opacity: 0.6;
transition: opacity 0.3s ease-in-out;
}
.product__thumb-item.active img {
opacity: 1;
}
{% endstyle %}
I hope this helps
Best,
Daisy
Hello @DaisyVo Thank you for replying. However, this solution is not working. Could you please check again and try to help? I would highly appreciate your assistance.
Can you take a picture of where you added the code?