Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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 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 %}
<p>
<img src="{{ safe_photo | file_url }}" alt="Safe place photo" style="max-width: 100%; height: auto; border-radius: 8px;" />
</p>
{% endif %}
and this, where it just returns the gid: link
{% assign file = order.metafields.my_fields.safe_place_photo %}
{% if file != blank %}
<p>Photo URL: <a href="{{ file | file_url }}">{{ file | file_url }}</a></p>
{% 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 %}
<p>Photo URL: <a href="{{ file | file_url }}">{{ file | file_url }}</a></p>
{% 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 ?