How to reference alt text from an image with liquid?

I am putting in an image from a collections metafield via Liquid code {{ collection.metafields.namespace.key.value | image_url }}.

But how do I reference and output that images alt text?

Hi @mns-burg

Welcome to Shopify Community.

You can access the alt tag from image using the image liquid object.

For e.g., if you are fetching an collection image, the image object will be fetched using collection.featured_image.

& you can use collection.featured_image.alt to get the value of the alt tag.

Thank you.

Sajat


If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.

1 Like

Thank you very much.
This was giving me a major headache, to wrap my mind around.
You answer helped me find the solution.

{{ collection.metafields.namespace.key.value.alt }}

Hi @Sajat and sorry for this question.

I show an image in the product page with an image metafield.
The image is shown but the alt text is missing.


{% if product.metafields.custom.brand_image != blank %}
 β€˜
{% endif %} 

So my problem is that the output do not show the alt text of image.
The alt text of image is set by the Shopify admin.

I try to with this but do not work:


Any ideas to solve?

Hi @Bardill

Can you please share your store URL, the page on which alt text is not getting displayed and the liquid code of your implementation?

It will help me to be precise with my answer.

Thank you.

Hi @Sajat

Thanks for your answer.

I cannot share URL because it’s dev and i have a problem of privacy.

Please you help me to understand what is the problem?