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.

Dear Kjdointhings,

In which file should the above code be placed? Thank you in advance!