How do I register a public asset in a plugin?

AI-generated summary

Users are facing issues with registering public assets in Discourse plugins, specifically when trying to access images on a private members-only site. featheredtoast shared their problem with the Discord oauth plugin, and Nikolay also reported the same issue.

simon provided the solution by referencing an old Discourse plugin, trout_emoji, which demonstrates how to register public assets. The key is to add images to the public/images directory in the plugin, and they will be available on the server at /plugins/plugin_name/images/, where plugin_name is the name specified in the plugin.rb file metadata.

Nikolay confirmed that this solution worked, and the problem was due to a misunderstanding of the plugin name in the path.

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?

مرحبًا، هل يمكنني الحصول على معلومات أيضًا؟ لأنني أواجه نفس المشكلة.

بالتأكيد، تم حذف هذا الموضوع. كان الموضوع يحتوي على رابط إلى إضافة قديمة لـ Discourse تحتوي على مثال يوضح كيفية تسجيل الأصول العامة في إضافة: GitHub - eviltrout/trout_emoji: Adds an evil trout emoji to a discourse install · GitHub.

آخر مرة اختبرت فيها هذا، فإن إضافة صور إلى إضافة في مجلد public/images سيجعلها متاحة على الخادم في /plugins/plugin_name/images/.

اسم الإضافة الذي تستخدمه في المسار هو اسم الإضافة الذي تحدده في البيانات الوصفية في أعلى ملف plugin.rb، على سبيل المثال /plugins/trout_emoji/images/trout-square.jpg.

شكرًا جزيلاً. الآن يعمل بشكل صحيح. كانت المشكلة لأنني اعتقدت أن اسم الإضافة في المسار هو اسم المجلد :slight_smile: