Restrict uploads

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.



Install this theme component


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 have try this components but its not working.

Can @tshenry help me?

This are the screen shot of my installation. I want to restrict user who have trust level 2 or below

1 Like

Hi there :wave:

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.


:warning: 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.



Just posting to note this:

I think it is broken (for Admins and Mods) on 2.6.0.beta2, but I’m unable to get more confirmation besides my own experience.


Thanks so much for the report @Iceman! I just pushed a fix that should get things back on track :slight_smile:
Let me know if there are any issues after you update the component.


Just tested and works just as before, that is, like a charm!

Thank you very much!


doesn’t restrict avi uploads

would be nice if it did

Can you elaborate a little more?

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´)


  • 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 :love_letter:


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.


Hi @Iceman. Thanks for the report, the issue is fixed by FIX: Do not error mobile upload button if !allowUpload by martin-brennan · Pull Request #14317 · discourse/discourse · GitHub which is in tests-passed now.