Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have created a new metafield for an image file.
I am successfully outputting the image with the following code:
{{ product.metafields.product_fields.full_width_image | image_url: width: 2000 | image_tag: alt:, srcset: nil, class: 'full-image' }}
The 'Alt Text' is not being output. I've followed the instructions provided here and double checked the image does have alt text (doh):
You can use the alt keyword argument to set alt text for the image.
If no value is provided, then the media alt text is used. If no image description is available, then this value will default to an empty string.
Any help appreciated
The answer for anyone that struggles with this is :
{{ product.metafields.product_fields.full_width_image | image_url: width: 200 | image_tag: alt, srcset: nil, class: 'css-class-1 css-class-2' }}
I had a colon (:) after alt.
Update to this, leaving the alt off completely returns the alt text used for the image.
{{ featured_image | image_url: width: 200 | image_tag: srcset: nil, class: 'product-card__image_second' }}
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024