Shopify CDN 的资产 URL 是如何生成的? [英] How is the asset URL generated for the Shopify CDN?

查看:23
本文介绍了Shopify CDN 的资产 URL 是如何生成的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在 Shopify 上上传了一张名为logo.png"的图片.

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

在流动模板中,我可以为它生成一个 URL,如下所示:

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

{{ 'logo.png' | asset_url }}

这会生成一个 URL,例如:

This generates a URL such as:

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

我想在 Shopify 之外生成此 URL 以在第三方应用中使用.

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

来自 https:/的 Shopify 代码/github.com/Shopify/pixelprinter/blob/master/app/liquid/filters/shop_filter.rb#L84

我可以看到如何使用商店 ID 生成除 '/t/2' 段之外的所有内容.

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

是什么决定了这最后一段?

What determines this final segment?

推荐答案

您不应依赖于以特定方式生成的 url.正如您所指出的,您可以在液体中使用 asset_url 过滤器,并且可以使用 Asset API从应用中获取资产的网址.

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.

如果您只是好奇,那么我相信您案例中的最后一段指定它是一个 id 为 2 的主题.

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

这篇关于Shopify CDN 的资产 URL 是如何生成的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆