No More Mismatched Images: Fixing Shopify Product Variant Photos When Sizes Are Out

Ever had that moment when a customer selects a product variant on your Shopify store, say a specific color, but then chooses a size that's out of stock or simply not offered? Instead of seeing just the selected color's images, suddenly your entire product gallery floods the screen with every single photo you have! It's frustrating, confusing for customers, and definitely not the polished look we aim for.

This exact scenario recently sparked a lively discussion in the Shopify community, initiated by Geronim0, who was grappling with this very issue on their store. When a size variant was unavailable, all product photos displayed, and on mobile, things got even weirder with numbers showing up instead of proper gallery navigation. Let's dive into what the experts and fellow store owners had to say and how you can tackle this common problem head-on.

Understanding the Root Cause: Shopify's Variant Logic

First off, let's clear up a common misconception: you absolutely do NOT need to delete and recreate your products. That's a huge sigh of relief, right? As Francesco Guiducci from IFG eCommerce and Devcoder both emphasized, your product and variant structure is likely fine. The core issue lies in how Shopify's system handles two distinct things:

  1. Selecting a valid variant (e.g., Black Silver, 10 oz).
  2. Deciding which media (photos) belong to the selected color or variant.

The problem arises when a customer picks a color (like "Black Silver") but then selects a size ("10 oz") that doesn't actually exist as a variant combination in your Shopify admin. When that specific combination doesn't exist, Shopify has no actual variant object for it. Many themes, when they can't find a complete, existing variant object to reference, simply fall back to showing the entire product gallery, losing the context of the selected color.

Here's a visual of what Geronim0 was seeing:

Screenshot of incorrect variant display on desktop

The Cleaner Approach: Decoupling Media from Variant Availability

The consensus from experienced community members like Francesco and Devcoder leans towards a more elegant solution: making your product gallery depend primarily on the color selection, not the complete variant's availability. This means if a customer chooses "Black Silver," the gallery should display only Black Silver photos, regardless of whether "10 oz" is available, sold out, or not offered at all. Variant availability should then independently control the "Add to cart" button's state.

Step-by-Step Diagnosis and Solution Path

Before you dive into any code, here's a structured way to approach the fix:

1. Check Your Product Setup in Shopify Admin

Vividusdesigns highlighted this crucial first step. Ensure your images are correctly assigned:

  • Go to your Shopify Admin, navigate to the problematic product.
  • Scroll down to the "Media" section.
  • For each image, click on it and verify that it's associated with the correct color variant(s). You can assign an image to multiple variants if it applies. This tells Shopify which images belong to which options.

2. Test with an Untouched Theme Copy

This is a critical diagnostic step recommended by Francesco:

  • In your Shopify Admin, go to "Online Store" > "Themes."
  • Find your current theme and click "Actions" > "Duplicate."
  • Once duplicated, click "Actions" on the new copy and then "Preview."
  • Navigate to the problematic product on this untouched theme. Does it behave correctly?

If it works perfectly in the clean theme, the issue is almost certainly in custom code or modifications you've made to your live theme's variant/media logic. If it behaves the same way, then the problem is more deeply rooted in how your theme was built to associate media with variants.

3. Theme-Specific Settings (Especially for Dawn)

If you're using Shopify's popular Dawn theme, vividusdesigns offers a specific setting to check:

  • Go to "Online Store" > "Themes" > "Customize."
  • Navigate to "Products" > "Product template."
  • In the "Product information" section, look for and enable the option: "Hide other variants’ media after selecting a variant." This setting often resolves general variant image display issues.

4. Adjusting Theme Logic (The Developer's Touch)

If the above steps don't fully resolve it, especially if the clean theme still misbehaves, it points to needing to adjust your theme's underlying code. The goal here, as Devcoder reiterated, is that:

  • Selecting any color shows only the images for that color.
  • The selected size does not affect which color images are displayed.
  • If a particular size is unavailable, the color's images are still displayed normally.

This usually involves modifying your theme's JavaScript or Liquid files that handle variant selection and media filtering. You'd want the gallery to filter images based on the option1 (usually color) value selected, rather than waiting for a complete and available variant object.

A Different Path: Creating All Variant Combinations

While Francesco and Devcoder advised against it for cleaner data, v.marychenka offered an alternative that some themes might require: explicitly creating all variant combinations in your Shopify admin, even if you don't stock them. For example, if "Black Silver" only exists as a "12 oz" variant, you'd also create a "Black Silver" + "10 oz" variant. Then, you'd assign the black photo to this new, out-of-stock variant.

  • Go to your Shopify Admin, navigate to the product.
  • Under the "Variants" section, click "Add variant."
  • Enter the missing combination (e.g., "Black Silver" and "10 oz").
  • Click the image icon next to this newly created variant and pick the appropriate photo.

This ensures that Shopify always has a variant object to return, even for unavailable combinations, which some themes might need to correctly filter images. Be aware that this can lead to a lot of extra variant data if you have many options and combinations.

Don't Forget Mobile!

Geronim0's mobile issue, where gallery navigation controls appeared as plain numbers instead of styled dots, is generally a separate presentation problem. This usually points to a CSS or styling issue where the theme's stylesheet isn't loading correctly or is being overridden for those specific gallery controls. It's not typically tied to the variant data problem, so you'd diagnose it independently by inspecting the mobile browser's developer tools to see which styles are (or aren't) being applied.

Screenshot of mobile variant display error with numbers

Wrapping It Up

The key takeaway from the community discussion is clear: don't rush to recreate products. Start by verifying your variant image assignments in the Shopify admin, then test your theme on a duplicate copy. If you're on Dawn, check that specific setting. For a robust, long-term solution, aim to adjust your theme's variant/media logic so that your gallery filtering is driven by the selected color option, irrespective of the size's availability. This keeps your product model accurate and provides a much better experience for your customers, ensuring they always see the right product photos, even if their desired size isn't currently in stock. Happy selling!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases