how to access product image metafields in product.liquid

New Member
4 0 0

Hello,

I successfully created a product_image metafield as referenced here: https://docs.shopify.com/api/product_image#update

I can verfy that this metafield has been created by viewing the raw json, but I can't seem to figure out how to access it in my product.liquid file. 

I have tried doing

    {% for image in product.images  %}
        {{ image.metafields.marketing.marketing_text }}
    {% endfor %}

but I can't seem to access the metafield. I have looked through the documentation and I can't find any information about this. Any help is much appreciated!

Thank you,

Tim

0 Likes
Shopify Expert
9811 92 1561

Last time I checked Liquid didn't return metafields on an image - with the single exception being the alt tag.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
1 Like
New Member
4 0 0

Jason,

Thank you for your response. So I can create metafields for product images, but I can't access them in liquid.. Interesting. I should be able to store the relevant info in the alt tag instead. 

 

0 Likes
Shopify Partner
94 5 8

Hi Jason,

I also can't see to Update the ALT tags with API calls, however I can for sure create it.

Am I missing something?

Thanks,

Amar

 

 

0 Likes
Shopify Partner
94 5 8

Hi Jason,

 

I figured out the way to update the ALT text of an image, however this seems pretty bad to me since there are a lot of API calls involved:

1) GET request to ->'/admin/metafields.json?metafield[owner_id]=850703190&metafield[owner_resource]=product_image'

2) GET THE ID

3) PUT request to 'admin/metafields/{{ID}}.json

 

Is there a better way to do that?

 

Thanks again,

Amar

 

 

0 Likes
New Member
3 0 0

I am also trying to access image metadata in liquid. Has anything changed since 2015?

0 Likes