Перейти к содержимому

Shopify Multiple Variant Images - (How to Display Images Specific to the Selected Variant)

Coding with Jan - Shopify Developer

0:00 / 0:00

Shopify Multiple Variant Images - (How to Display Images Specific to the Selected Variant)

99 995 просмотров · 3 г. назад
Coding with Jan - Shopify Developer
62,7 тыс. подписчиков
99 995 просмотров · 3 г. назад
👨‍🎓 Automate More. Build Faster. Land Better Opportunities with AI: https://codingwithjan.com/ai-develope... 🎬 About this Video By default a Shopify product page shows every image at once, even when a customer has picked a specific color. In this tutorial we fix that so only the images belonging to the selected variant are shown. It's a bit more advanced because we write JavaScript as well as Liquid. Josie breaks it down step by step: grouping images by alt text, using a Liquid conditional to hide thumbnails that don't match the featured image (handling the case where a variant has no featured image too), then adding JavaScript in global.js so the images switch instantly when the variant changes instead of needing a page refresh. Works in the Dawn theme and the free themes that share its code base. ⏳ Timestamps 00:00 Intro 00:26 The Goal & Grouping Images by Alt Text 02:28 Filtering Thumbnails with Liquid 05:58 Why We Need JavaScript 06:58 The Variant Change Function 10:50 Looping to Hide and Show Thumbnails 15:08 Final Result 🔎 SEO Description How to display images specific to the selected variant on a Shopify product page, so only the images for the chosen color show instead of all of them. This tutorial covers grouping product images by alt text, filtering thumbnails with a Liquid conditional (including variants with no featured image), and writing JavaScript in global.js to update the images instantly on variant change without refreshing. Works with the Dawn theme and free themes sharing its code base. An intermediate Shopify theme development tutorial with Liquid and JavaScript. 🔗 Resources Add color swatches to your variant selectors (companion tutorial):    • Shopify Tutorial - How To Add Color Swatch...   🤝 Connect on LinkedIn:   / jan-frey   📧 Contact: https://codingwithjan.com