How is the asset URL generated for the Shopify CDN

2019-07-29 10:14发布

问题:

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.



标签: api cdn shopify