Shopify themes, liquid, logos, and UX
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.
Solved! Go to the solution
This is an accepted solution.
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 ,
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?
This is an accepted solution.
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!
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025