This is a very small theme component that will remove the upload button from the composer toolbar and disable drag-and-drop uploading for users that are under a specified trust level.
My forum is pushing 1.1GB in uploaded media. Weāre growing in a way I wasnāt super prepared for and have been trying to coerce users to use places like imgur instead. This really, really helps!
I just checked and it appears to be working correctly. Can you make sure you have added the Restrict Uploads component to your main theme? You will also need to hard-refresh the page for the component to take effect. Oh, and make sure the account you are using for testing is not a staff user.
A note to anyone using this component - there is an update to the component that requires you to be running the latest tests-passed version of Discourse. If your Discourse site is not up to date, DO NOT update the component as it will reference core code that you do not have yet which will break the composer functionality of your site.
Thanks so much for the report @Iceman! I just pushed a fix that should get things back on track
Let me know if there are any issues after you update the component.
I just tried uploading an AVI from a trust level lower than the one defined in the restrict to trust level theme setting and it prevented the upload as expected.
If you would like to prevent non-staff users from uploading AVI files specifically, you should ensure the AVI extension isnāt added to authorized extensions. You can add the extension to authorized extensions for staff if you want staff to be able to upload AVIs.
it is really cool.
Could it separate the restriction between post and personal message?
for example, only allow staff upload image in personal message but tl2 can upload images in normal post
Hey, just want to point out that this ābreaksā with Discourse Latest ( 2.8.0.beta6 (0d809197aa) ).
TypeError: null is not an object (evaluating Ā“this.mobileUploadButton.addEventListenerĀ“)
Details:
Started to happen after a Rebuild (and therefore, update to latest).
This only happens on Mobile.
Doesnāt happen on all browsers, neither on all devices (could be a cache thing? idk). But once it happens there is no way to āfix itā from a userās perspective.
The behavior is weird because it āchangesā how the buttons behave. The ādiscardā button (trash can) and Preview buttons reload the page. The āDiscourse Gifs Theme Componentā Button just expands the composer.
I thought it was some compatibility issue with the āDiscourse Gifsā Theme Component but if I disable that one the issue persists.
I can provide more details if necessary. I tried removing as much as possible but it seems that he problem only stops happening after disabling this Theme Component.
btw, just want to use the opportunity and point out what a great Theme Component this is and how much I do think that it should be a core feature
Thanks for reporting this! There has been some recent work on our core upload system and there appears to be a little bug. Iām actually able to reproduce the error even without the component under the right circumstances. Iāll pass this by the engineer thatās been focusing on uploads to see if we can get this fixed up!
That sounds like a reasonable feature request! Iāll see what I can do.
[THEME 6 āRestrict Uploadsā] To prevent errors in tests, add a pluginId key to your modifyClass call. This will ensure the modification is only applied once.
Just thought to raise it as it may become a potential issue once the recent changes go live for everyone.