返回介绍

Extension Assets

发布于 2024-06-22 20:04:58 字数 1305 浏览 0 评论 0 收藏 0

Some extensions might want to include assets like images or JSON files in their source code (note that this is not the same as uploads, which would probably require a filesystem disk).

This is actually very easy to do. Just create an assets folder at the root of your extension, and place any asset files there. Flarum will then automatically copy those files to its own assets directory (or other storage location if one is offered by extensions) every time the extension is enabled or php flarum assets:publish is executed.

If using the default storage driver, assets will be available at https://FORUM_URL/assets/extensions/EXTENSION_ID/file.path. However, since other extensions might use remote filesystems, we recommend serializing the url to assets you need in the backend. See Flarum's serialization of the logo and favicon URLs for an example.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文