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 Likes

Hello, can i get information too? Because i am facing the same problem.

Sure, that topic was deleted. The topic gave a link to an old Discourse plugin that has an example of how to register public assets in a plugin: GitHub - eviltrout/trout_emoji: Adds an evil trout emoji to a discourse install.

The last time I tested this, adding images to a plugin in the public/images directory will make them available on the server in /plugins/plugin_name/images/

The plugin name that you use in the path is the plugin name that you give in the metadata at the top of the plugin.rb file, for example /plugins/trout_emoji/images/trout-square.jpg

4 Likes

Thank you very much. Now it is working. Problem was because i thought that plugin name in path is folder name :slight_smile:

1 Like