How do I register a public asset in a plugin?

Forgive me if this has been asked before, but I am unable to find a previous topic on this.

I’m wondering how to register an asset as public (such as an image) through a discourse plugin - it seems currently after registering, I get a 404 or 302 response when installing under a private member’s only site.

This is in reference to the Discord oauth plugin I built - I am unable to retrieve the image either directly, or through a register_asset call.

How would I go about serving static plugin assets in this case?

「いいね!」 3

こんにちは、私も情報をいただけますか?私も同じ問題に直面しています。

はい、そのトピックは削除されました。そのトピックには、プラグインでパブリックアセットを登録する方法の例を示す古い Discourse プラグインへのリンクがありました:https://github.com/eviltrout/trout_emoji。

私が最後にテストした際、public/images ディレクトリに画像を追加すると、サーバー上で /plugins/plugin_name/images/ として利用可能になります。

パスで使用するプラグイン名は、plugin.rb ファイルの上部にあるメタデータで指定するプラグイン名です。例えば、/plugins/trout_emoji/images/trout-square.jpg のようになります。

「いいね!」 6

どうもありがとうございます。これで動作するようになりました。問題は、パス内のプラグイン名がフォルダ名だと思っていたためでした :slight_smile:

「いいね!」 1