As far as I am aware the metafield with this setup should return a generic_file object that should allow access to id, media_type, preview_image, and url.
When trying to access on a product page using the liquid code {{ product.metafields.my_fields.product_instructions.url }} I get nothing returned.
However when using {{ product.metafields.my_fields.product_instructions }} on a product page where the product has a file metafeild set the follwing is returned gid://shopify/GenericFile/22363445657783
When no metafield is set as expected nothing is returned.
I was expecting to be returned a generic file object as per the metafield object docs. From which I could access id/media_type/preview_image/url as per the generic_file object docs.
Interestingly it instead appears to return a type of Metafields::MetafieldDrop which I can’t find any reference to anywhere. This can be seen if you try to use something like asset_url where you get the error “Liquid error (sections/test.liquid line 1): Expected input to be a String but got Metafields::MetafieldDrop”
I’ve used the below code instead, utilising the file_reference metafield filter which works for my uses, but it is not what I had expected from the docs.
And none of these methods appear to work within email notifications. @Shopify_77 , what is the correct way to generate a PDF file_reference url within an order notification template?
I am having this problem as well, and have tried everything suggested in this thread. Sometimes the below liquid works as expected and it creates a url link to the file (a pdf in my case), but most of the time I get a liquid error that reads “Liquid error (sections/main-product.liquid line 310): internal”.
Also getting this problem. Appending ‘.url’ on the end of the metafield path doesn’t work as expected. Putting it through the ‘file_url’ filter does work.
NOTE: This differ greatly when you have a list of file metafield, like the sample above. The console log result is an array and we need to loop the values, to call each file.
FIXED: Shopify Metafield List of Files not returning image URLs (MediaImage GID issue)### My Problem
Using a List of files metafield (e.g. for additional product images) and getting: Empty image renders
invalid url input errors
GIDs like [“gid://shopify/MediaImage/1234567890”] instead of usable URLs
.url, file_url, and even media_image_url not working
Cause
Shopify does not auto-resolve List of Files metafields to full MediaImage objects by default. Even though the admin UI shows thumbnails, Liquid returns raw GID strings, unless you use .value.
Solution for my implementation fetching images.
{% assign files = product.metafields.custom.additional_images.value %}
{% for file in files %}
{% endfor %}
Why this works
.value gives you real MediaImage objects from a list of files
| image_url handles Shopify’s CDN path + optional width
Works cleanly in Online Store 2.0 themes
Hope this helps in any capacity, fun thing to debug rewarding solving it.