Shopify CDN 的资产 URL 是如何生成的?

编程入门 行业动态 更新时间:2024-10-21 10:11:15
本文介绍了Shopify CDN 的资产 URL 是如何生成的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

假设我在 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/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 06:44:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/932744.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:资产   Shopify   CDN   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!