Shopify Product Gallery: Display Only Selected Variant Images for Better UX & Speed
Hey everyone! As a Shopify expert who spends a lot of time digging through community discussions, I often see common pain points that can significantly impact your store's performance and customer experience. One such issue popped up recently in a thread titled "Tinker - Displaying only selected variant images" – and it's a super important one for anyone selling products with multiple variants and lots of photos.
Our friend @janekkmn brought up a classic challenge: they had garments with several images per variant (think different angles or details for a "Red" shirt), but even after turning on Shopify's "hide images of unselected variants" setting, their product gallery was still showing a ton of irrelevant photos. This isn't just visually messy; as @janekkmn rightly pointed out, it was "killing my performance by downloading 20+ images"! Ouch. That's a huge red flag for page load times and conversion rates.
Why Shopify's Default Setting Falls Short
It's a common misconception that Shopify's built-in "hide images" option will magically filter your entire gallery. As @Mustafa_Ali and @Easify-Jennifer explained, Shopify natively links only one featured image to each variant. So, when you select a variant, that setting really just ensures that single linked image is shown, while other single linked images for other variants are hidden. The rest of your product gallery – all those extra shots you uploaded – often remain visible, leading to a cluttered view and unnecessary image downloads.
This is where the community really shines, offering up some fantastic solutions to tackle this.
Community Insights: Two Paths to a Cleaner Gallery
The discussion quickly highlighted two main routes for achieving that perfectly filtered product gallery:
1. The App Route: An Easy, No-Code Solution
For store owners who prefer not to dive into code, a Shopify app can be a great alternative. As @marley_45 suggested (with full disclosure of working for Orichi, makers of Swatchy), variant image apps are designed to group all photos per variant and load only the selected set. This is a straightforward way to get the desired functionality without needing to edit your theme's files.
2. Custom Code: For Control and Performance
If you're comfortable with a little custom coding – or you have a developer on hand – this path offers maximum control and, when done right, the best performance. The general consensus from @namphan, @Easify-Jennifer, @devcoders, and @Mustafa_Ali was clear: you'll need some custom JavaScript to dynamically filter your product gallery.
The key idea here is to "tag" your images. While @janekkmn mentioned their filenames already included variant slugs, the experts recommend using image alt text. It's often more reliable and easier to manage. The process typically involves:
- Detecting when a customer selects a new variant.
- Reading the alt text (or filename) of all product images.
- Comparing those tags to the selected variant's value.
- Dynamically displaying only the matching images (and any "untagged" shared images like a size chart).
Crucially, as @Easify-Jennifer and @devcoders emphasized, simply hiding images with CSS isn't enough for performance. You need to ensure those hidden images aren't unnecessarily downloaded in the first place, or at least that they're lazy-loaded. This is where well-implemented JavaScript comes in.
Deep Dive: A Free Solution for the Tinker Theme (and Beyond!)
The real gem in the thread came from @Ploqo, who provided a fantastic, free, step-by-step solution specifically for the Tinker theme! This is a brilliant example of community members helping each other directly. Here's how to implement it:
The core idea is to use the image's alt text to tell your theme which variant it belongs to. Images without alt text will be treated as "shared" and shown for all variants.
Step-by-Step Instructions:
- Go to Products in your Shopify admin and open the product you want to modify.
- Click the first image of a specific color or variant.
- In the Alt text field, type the variant name exactly as it appears in your variant options (e.g., "White" for a white shirt variant). Save your changes.

- Repeat this process for every image that belongs to that specific variant. Important: Leave the Alt text field empty for any images you want to be "shared" across all variants (like a size chart, or general lifestyle shots).
- Now, go to Online Store > Themes in your Shopify admin and click Customize on your Tinker theme.
- Navigate to a product page within the customizer. In the left sidebar, click on Product information.
- Scroll to the bottom of the "Product information" section, click Add block, and choose Custom Liquid.

- Paste the following code exactly into the Custom Liquid box:
{%- liquid
assign vf_opti
-%}
- Click Save.
Now, when you pick another color on your product page, you'll see only that color's images, plus any shared ones. Check out the "Before" and "After" shots @Ploqo shared – it makes a huge difference!


This code works by "booting" on page load and then listening for changes in your variant selection. When a new variant is chosen, it quickly identifies the corresponding images based on their alt text and adjusts their display properties, ensuring only the relevant ones are visible. The use of el.style.display = show ? '' : 'none'; and el.hidden = !show; helps manage visibility and can influence how browsers handle image loading, contributing to better performance.
Final Thoughts on Performance and User Experience
Whether you choose an app or implement a custom code solution like the one above, the goal is the same: a streamlined, high-performing product page. Preventing unnecessary image downloads is absolutely critical for your store's speed, especially on mobile devices. A faster site means a better user experience, lower bounce rates, and ultimately, more sales. It's a small change that can have a massive impact on your bottom line.
So, if you're struggling with variant images cluttering your product pages or slowing down your store, give these solutions a shot. It's fantastic to see the Shopify community come together to solve these real-world problems for store owners. If you're looking to start your own online store and build a robust e-commerce presence, consider exploring what Shopify has to offer – it's a powerful platform, and with a bit of customization, you can truly make it your own!