Reputation: 15213
I have a metafield of type document
, and in the ajax query I get the value of this field as
"gid://shopify/GenericFile/31146481287411"
I need the url. I can easily get that url in liquid using file_url
:
{{ metafields.custom.document | file_url }}
But I need to get the url specifically in javascript!
Please tell me how I can do this, and is there a workaround? Thank you.
Upvotes: 1
Views: 572
Reputation: 11427
Store the file url in a string metafield, and get that instead of the GID to a resource. Alternatively, since your JS has to run AFTER Liquid rendering, render the URL into a JS variable and use it as you wish. You have plenty of options.
Upvotes: 1