order file metafield url

Hi I have a file metafield setup on my orders page that I add an image to and I am trying to fetch the publicly accessible cdn link (so my customers can view the image) and add this to the order shipped email.

I keep getting the gid: url which isnt publicly accessible.

All the Photos are uploaded to my internal Shopify files all of which have a public link.

Does anyone know of a way to fetch this public link and display it in a notification email?

Many thanks

Can you share a code you’re using?

I guess you’re missing some .value properties and file_url filters…

Hi @tim_1 Ive tried this, which it doesnt display the photo in the email…

{% assign safe_photo = order.metafields.my_fields.safe_place_photo %}
    {% if safe_photo != blank %}
      

        
      

    {% endif %}

and this, where it just returns the gid: link

{% assign file = order.metafields.my_fields.safe_place_photo %}
{% if file != blank %}
  

Photo URL: {{ file | file_url }}

{% endif %}

I’d really appreciate any suggestions on how to display public link.

Many thanks

Have you tried

{% assign file = order.metafields.my_fields.safe_place_photo.value %}

Because it is .value actually turning a gid into an object.

I have just tried

{% assign file = order.metafields.my_fields.safe_place_photo.value %}
{% if file != blank %}
  

Photo URL: {{ file | file_url }}

{% endif %}

But unfortunately it didn’t return anything.

If you have any other suggestions they would be greatly appreciated!

Not much I can suggest from the outside. Try https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-file_reference ?