如何通过 Zotonic 之外的 ID 链接到媒体项目?

发布于 2024-09-29 23:25:27 字数 464 浏览 7 评论 0原文

创意团队希望能够使用 Zotonic 来管理主网站之外使用的图像。为了做到这一点,他们目前链接到图像如下:

<img src="http://example.com/media/inline/2010/10/29/image.jpg" />

这有一个巨大的缺陷。每次在 Zotonic 中替换其中一张图像时,文件名都会发生变化。如果替换发生在不同的日期,则文件的路径会发生变化。这意味着他们必须替换 Zotonic 中的图像,然后更新其他网站上的 HTML。

想象一下,有问题的媒体项目的 ID 为 575。我想让它们链接到图像,如下所示:

<img src="http://example.com/media/575" />

How do you link to a media item by ID Outside Zotonic?

The creative team wants to be able to use Zotonic to manage images used outside of the main website. In order to do this they are currently linking to images as follows:

<img src="http://example.com/media/inline/2010/10/29/image.jpg" />

This has a huge flaw. Every time an one of these images is replaced in Zotonic the filename can change. If the replacement happens on a different day the path to the file changes. This means that they have to replace the image in Zotonic and then update the HTML on the other sites as well.

Imagine that the Media item in question has ID 575. I would like to let them link to images as follows:

<img src="http://example.com/media/575" />

How do you link to a media item by ID outside Zotonic?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪我终i 2024-10-06 23:25:27

阅读您的问题后,我对 resource_file_readonly 做了一个小更改,并添加了两个 dispath 规则:

{media_attachment, ["media","attachment","id",id], ... },
{media_inline, ["media","inline","id",id], ... }

它允许像这样的图像标签:

<img src="http://example.com/media/inline/id/575" />

此更改现在可以在默认分支(0.6-dev)的提示上使用。

After reading your question I made a small change to the resource_file_readonly and added two dispath rules:

{media_attachment, ["media","attachment","id",id], ... },
{media_inline, ["media","inline","id",id], ... }

Which allows an image tag like:

<img src="http://example.com/media/inline/id/575" />

This change is now available on the tip of the default branch (0.6-dev).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文