Shopify themes, liquid, logos, and UX
I am using Dawn theme. Most of my products have variant images. The problem is when the user clicks on the item to get to the product page, it automatically changes the image to the first variant's image. I'd like the main product image to stay until the user selects a variant from the drop down.
Hi @jenok ,
Please do the following steps:
- Go to Themes -> Edit code
Find and open the file product-media-gallery.liquid
Find the code:
{%- assign featured_media = product.selected_or_first_available_variant.featured_media -%}
And replace it with the following code:
{%- assign featured_media = product.featured_media -%}
Similarly, find all code:
{%- unless media.id == product.selected_or_first_available_variant.featured_media.id -%}
Replace everything with the following code:
{%- unless media.id == product.featured_media.id -%}
Hope it works @jenok
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
B2B Solution & Custom Pricing | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Hi - I will definitley try this- thank you!
Can you please clarify though what does the "media.id" part of this do? Do I have to do both?
"media.id" is the product's image ID. In this case, the image will be displayed if the id is the id of the main image or because of the image of the first variant. You need to follow all the steps I instruct you to display correctly.
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
B2B Solution & Custom Pricing | Product Labels by BSS
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Hi - Understood... I did both replacements of code. They worked great. But some products do not show pictures correctly when going into the product pages. For example, please go to my Halloween collection at https://yummaliciouschocolates.com/collections/halloween
If you click on the first product on this page - Halloween Gift Box - the first image does not appear at all. The images that do show are only as thumbnails. This happens to product #3 on the same row. But products #s 2 & 4 work perfectly. Then on row 2, products #1 &2 work, but #s 3 & 4 do not. I tried deleting the main image an re-uploading them. But this did not help. Any thoughts on how to fix this?
Hi! I've had the same problem and have replaced the snippets with the code you provided. Still, the product gallery media layout changes when you click another variant. Any idea how to fix that? Thanks a lot!
I am getting the same issue with the same image displayed twice and then some images not uploading properly. It is very close to being a correct fix.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025