Hello,
I’m hoping that I’m just doing this wrong and someone can shed some light on this for me. I am wanting to loop through the product object and return the first media asset that does not have a particular alt text. For example, I have products that have action shots and lifestyle shots. The action shots have “__action” in the alt text of those particular media assets.
This is what I currently have and I’m only getting the last item returned to me. I’d like to instead get the first image asset that does not contain “__action”.
{%- assign lifestyle_image = '' -%}
{%- for media in product.media -%}
{%- unless media.alt contains '__action' -%}
{%- assign lifestyle_image = media.src -%}
{%- endunless -%}
{%- endfor -%}