Please help - Product images are showing first variant rather than first photo

When landing on a product that has variants, the first variant option image is displayed instead of the first image available in the gallery. I’ve tried a few different code changes that haven’t worked. I really want the first image to display automatically and then the variant images to only show if selected.

I’m no coder so please make steps as simple as possible..

My theme is Craft v. 15.4.1

Website example: Hardcover Coptic Stitch Sketchbook – Book and Kettle Cottage Crafts

Thanks in advance!

Hi there,

You can fix this by making a small change in your theme code.

In Shopify Admin go to:

Online Store - Themes - Click “…” on Craft theme - Edit code

Open this file:

snippets/product-media-gallery.liquid

Find this line:

assign featured_media = selected_variant.featured_media | default: product.featured_media

Replace it with this:

assign featured_media = product.featured_media

This will make the product page always show the first gallery image when the page loads.

Thank you , that worked! It seems the other solutions sent me to the wrong file to begin with.

Hi @bookandkettle

Thank you for your response. It’s good to know that it’s worked for you. Kindly feel free to get back to me if you need any further assistance. If helpful, please like all posts. :white_check_mark:

Best regards,
Devcoder :laptop:

Just in case, here is the solution which does not require editing theme code – just adding a “Custom liquid” block to the product info section – Eternal issue of replacing variant image by featured image on product page (Trade 15.4.0) - #3 by tim_1

And it also only works if variant is not pre-selected in URL which can be handy if you, say filter collection by product color.
And it works in any theme from the Dawn family.