shopify - How to add alt to image in custom section
Solution:
Once you upload the image simply click on the image, and a popup appears on the popup there is a text field to add an alt tag for that image.
it looks like this image:
To get it on img tag you can use the default image_tag (https://shopify.dev/api/liquid/filters/image_tag)
{{ section.settings.img_section_image | image_url: width: 200 | image_tag }}
it shows the alt tag automatically when img tag is created or use the
{{ section.settings.img_section_image| image_url: width: 200 | image_tag: alt: 'My image's alt text' }}
To add manually custom tag, without backend.
if you do not useimage_tag
, then try something like this
<img src="{{ section.settings.img_section_image | img_url: '960x645'}}" alt="{{section.settings.img_section_image.alt}}">
I hope this will helps you and other as well
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.