How can I set product images to change based on collection?

Topic summary

A store owner wants to display different product images for unisex apparel based on collection context—showing male models in men’s collections and female models in women’s collections.

Original Request:

  • Display 2nd product image when collection title contains “men’s”
  • Otherwise show featured (1st) image
  • Using Empire theme from Pixel Union

Solution Provided:
A contributor identified the product-grid-item snippet and provided Liquid code that:

  • Checks if collection.url contains ‘/mens’
  • Shows product.images[1] (2nd image) for men’s collections
  • Shows featured image for all other collections
  • Maintains existing hover/alternate image functionality

Enhancement:
Later refined to target only unisex products by adding a tag check:

{% if collection.url contains '/mens' and product.tags contains "unisex" %}

Ongoing Questions:
Multiple users (posts 9-15) struggle to locate the correct file/snippet in their themes (Dawn v14, Split themes, non-Dawn themes). The original solution was theme-specific to Empire.

Alternative:
One user recommends the “EZ Product Image By Collection” Shopify app as a no-code solution.

Status: Original issue resolved, but implementation guidance needed for different theme architectures.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

This is definitely possible. From looking at your source code I’m going to assume you have a snippet called product-grid-item or something similar. This is the snippet that holds the code for the product tiles on your collection pages. Inside that snippet, look for the figure element with a class of productitem–image. Inside this element you’ll want to add some logic to determine what product image to show.

Two simple options would be to make use of the image alt text or the image file name to specify whether the image is a male or female. Then in your liquid you can check if the collection handle contains ‘womens’ or ‘mens’ (in that order because ‘womens’ also contains ‘mens’). If you’re in a mens or womens collection, you can then loop over the product images and check the file name or alt text for “male” or “female” and use that image. If the collection is not mens or womens, show the product featured image as it does now.

Alternatively, to optimize this, you could update all unisex products so that the male image is first, and the female image is the 2nd image. Then instead of adding male or female to the alt text or file name, you could just output product.featured_image for the male photo and product.images[1] (the 2nd product photo) for female.

Happy to write out a more specific example if you can provide your code.