FROM CACHE - en_header

Possible breaking change recently launched? Related to metafields (.value) in themes.

Solved
DanAtBonify
Shopify Partner
35 3 15

We have an app that can store a path to an image in a metafield.

Previously, you could print out the image stored in the metafield as an image tag using the img_tag filter like:

{{ product.metafields.my_namespace["my_key"] | img_tag }}

 However, that now appears as a broken image, and .value must be applied to the metafield such as:

{{ product.metafields.my_namespace["my_key"].value | img_tag }}

 


This appears to be related to the new version of metafields detailed here. However, my impression was that old-format string/integer/json_string metafields would not need to be changed in the theme layer.

I am not sure, but there may be other places where passing the metafield directly into a filter would not work as expected, but img_tag is the only one I'm aware of so far.

I am curious if anyone else has noticed any strange behavior with their themes and metafields.

Accepted Solution (1)

Accepted Solutions
DanAtBonify
Shopify Partner
35 3 15

This is an accepted solution.

Okay, after having been in contact with Shopify it appears they have fixed this issue.

View solution in original post

Replies 4 (4)
OleACF
Shopify Partner
5 0 4

Adding a comment here for visibility. Didn't experience any issues myself

Accentuate Custom Fields | Undo
DanAtBonify
Shopify Partner
35 3 15

@OleACF Do you pass metafield values into filters in your app? We are still getting reports of users having suddenly broken liquid because they were passing a metafield into a filter, but appears that the new syntax is to add ".value" to the end of the metafield.

It has not been a super-common issue because it would have required the user to have customized some liquid to pass the metafield into a liquid filter. But it does appear that the behavior of such code has changed recently, related to the new metafield types is my guess.

DanAtBonify
Shopify Partner
35 3 15

This is an accepted solution.

Okay, after having been in contact with Shopify it appears they have fixed this issue.

JasonN
New Member
1 0 0

I'm still seeing `.value` required on JSON_STRING metafield types in order to access properties of the json object in liquid.

 

I also did a quick test of API version 2021-07 and the JSON metafield type to see if it would not require `.value` but still looks like it's required. Maybe that's an issue with editing an existing type=json_string metafield with type=json, not sure yet but will keep digging.