How is the asset URL generated for the Shopify CDN?

守給你的承諾、 提交于 2019-12-11 09:06:22

问题


Assume I have an image uploaded to a store on Shopify called 'logo.png'.

In a liquid template I can generate a URL for it like this:

{{ 'logo.png' | asset_url }}

This generates a URL such as:

http://static.shopify.com/s/files/1/0072/7952/t/2/assets/logo.png?100239

I want to generate this URL outside of Shopify for use in a third party app.

From the Shopify code at https://github.com/Shopify/pixelprinter/blob/master/app/liquid/filters/shop_filter.rb#L84

I can see how to use the shop id to generate everything except the '/t/2' segment.

What determines this final segment?


回答1:


You should not depend on the url being generated in a specific way. As you have pointed out, you can use the asset_url filter in liquid and you can use the Asset API to get the url for an asset from an app.

If you are just curious, then I believe the final segment in your case specifies that it is a theme with id 2.



来源:https://stackoverflow.com/questions/10953950/how-is-the-asset-url-generated-for-the-shopify-cdn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!