Get model3d file URL

Topic summary

A developer needed to retrieve the URL of a 3D model (.glb file) stored in a Shopify product metafield using Liquid templating.

Initial Problem:

  • Direct access returned only the model ID (gid://shopify/Model3d/...)
  • Using the file_url filter produced an error: “Cannot apply file_url to a 3D model, not supported”
  • Attempting to access sources[0].url returned an empty string

Attempted Solution:
Another user suggested assigning the metafield to a Liquid variable first, then applying the file_url filter, but this produced the same unsupported filter error.

Resolution:
The issue was resolved by accessing the nested value structure:

product.metafields.custom.canopy_model.value['3d_model_file'].value.sources[0].url

The key was adding .value before .sources[0].url to properly traverse the metafield object structure.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hello.

In my theme liquid file, I’m trying to get my model model3d (.glb) file URL. I can get the file ID by doing.

var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'] }}";
//Reulst: gid://shopify/Model3d/idofmymodel
var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'] | file_url }}";
//Using this gives me this error: Cannot apply file_url to a 3D model, not supported.
var glbModelFileUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'].sources[0].url }}";
//this gives empty string

I can’t figure out how to get the URL. I have the file attached to the product object in my metaobject.

HI @pzagor2 ,

Try assigning the object to a variable in liquid first like so:

{% assign glbModelFile = product.metafields.custom.canopy_model.value['3d_model_file'] %}

Then, try accessing the file url with that variable inside the output tag.

{{ glbModelFile| file_url }}

Let me know if this works.

If this was useful, a Like or marking it as a Solution is appreciated. Need more help? Feel free to reach out anytime using the email address/phone number in my signature.

Thank you for the suggestion, but unfortunately I get the same error:

Cannot apply file_url to a 3D model, not supported.

@pzagor2 Can you send me your 3D model here so I can try uploading it on my end and troubleshooting it?

I was able to get the URL with

window.model3dUrl = "{{ product.metafields.custom.canopy_model.value['3d_model_file'].value.sources[0].url}}";

@marcuswebexp Thank you for taking the time and helping.

Hi @pzagor2 ,

No problem. Happy to help!