Change the product image based on the language of your customer using the Dawn theme

I want to change the product images based on the customers langauge selected.

Reason is that some of the product images has text on them. I want to show the correct image for the correct users with their language selected. I have 2 languages only. English and Swedish.

Main language on the shop is Swedish, Translated language is / with Translate & Adapt = English.

I found this code, I managed to make “normal” images on the website to work. for my custom sections.
So I know how the logic works now. But I cannot find how to make it work for the products.
I mean, could I make like "if product name contains “sv” and language == ‘sv’ then return images with that variable or something? And hide the rest that is not with that variable in the name?

Can someone please help me!

{% if customer.locale == 'sv' %} {% include 'product-image' with image: product.image %} {% else %} {% include 'product-image' with image: product.featured_image %} {% endif %}

You need to ask a much more specific question.

This is an advanced customization and will vary wildly between themes even in describing what templates or logic to change.

For example in Dawn based themes you need to look at main-product.liquid and through the find it’s image|media gallery logic loop inserting your logic.

For something like this you probably want the logic to use something in the filename itself, or the alt-text as the keyword for which images are allowed to render.

So you’d want to dig through and find the approximate areas , try your code then try to be more specific with questions.

If you just need this customization done for you then contact me by mail for services.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.
Contact info in signature.

Hey , thank you for the answer.

I know basic coding and logics so on. Exactly what you are telling me is what I want to do. With either the alt text or file name to be displayed etc. Issue I have now is to find where and how the images are rendered for a product. What file in the DAWN theme can I fint the code that takes each producs images and display them?

Best regads

Hi @46855004463 ,

To change product images based on language in the Dawn theme, try the EZ Product Image Translate app. It allows you to upload and manage different images for each language without needing to code.

Best regards!