Limit number of images uploaded by user per day, wil TL multipliers

We currently can limit number of posts, likes and topics per user depending on their trust level.

Because disk volume is an expensive resource for huge but non-profitable communities, please add settings to control the number of images one can upload daily, depending on their trust level.

In our community, I found out that some users submit too many similar images, which just eat space and add no value to their posts compared to if there were fewer images. An example would be 20x images when 3-4 images would be absolutely enough.

3 Likes

You should address this with a site feedback topic on your community, first.

They should know that server disk space is not free. So don’t upload 20 images when 3 would do…

1 Like

Thanks for prompt reply. I’m doing so, but unfortunately it does not help. Especially with newbie users who still have to go through all Tutorials gradually.

2 Likes

One idea why they do upload many similar images is because there is a bulk upload feature. It might be easier to select all 20 images instead of choosing the best 3 to 4 images among them.

5 Likes

Would you say it is a plugin territory or a pr-welcome, or might become a planned feature?

I think plugin, personally. Setting image size limits globally, which you can already do, should be first.

1 Like

You mean the final image size after its upload and resize, right?

I mean, if I’m not mistaken, it allows to upload up to X MB images, but
will resize to Y dimensions and save only the resized version, is that how
it works?

Also, any way to resize down all existing images and those save another
~20% space?

@zogstrip can advise you on this.

Yes, that’s how it works. We allow users to upload images larger than the site setting and then try to downsize it to less than the maximum allowed.

You will have to manually run convert on all the images stored on your server (and hopefully they aren’t stored in S3).

1 Like

So, can the max upload size be regulated in the site settings anywhere, or is it just some big number by default?

After an image is uploaded, will it be resized to match the “max image size kb” setting?

May you recommend any “sane” minimum that would allow for images good enough for browsing on the Internet, but not good enough for printing and viewing fullscreen at big screens? It is currently set to 1024 KB, and I wonder if I can make it even smaller to save on space. Any advice?

They aren’t stored in S3. How do I run the convert, how save is it?
– Many thanks for your help

P.S. I think this would solve the issue, but still waiting for any official recommendations by the Discourse team.

@zogstrip, so I decreased the value of max_image_size_kb setting. But now, I cannot upload images from my mobile phone bigger than configured in the setting.

I got confused - how do I make this work?

Considering this comment of yours, I expect images up to 10MB should be acceptable when uploading:

Looks like the current behavior is a regression?

  • What value did you use for max_image_size_kb?
  • What’s the size of the image you’re uploading?
  • What error message did you get?
  • Have you changed the NGINX client_max_body_size setting? (By default it’s 10MB)
2 Likes

Thanks for your ongoing assistance.

864

~1.5MB

It says that the images I’m trying to upload is too big and I up to 864KB images are accepted.

In my app.yml I found only this piece that may be related to uploads, but it says 50m:

params:
  db_default_text_search_config: "pg_catalog.russian"
  ## Set db_shared_buffers to 1/3 of the memory you wish to allocate to postgres
  ## on 1GB install set to 128MB on a 4GB instance you may raise to 1GB
  db_shared_buffers: "256MB"
  #
  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed
  upload_size: 50m

Yeah, that’s the error message you get when we couldn’t resize your image down to the maximum allowed.

That’s indeed how to change the client_max_body_size value :wink:

1 Like

in other words, there’s a maximum acceptable quality loss that Discourse will take before giving up and saying “can’t resize it that small”.

2 Likes

Can we get such a message in place? It currently will just say that the image is too big, while it is not.

How can I solve the case when users post too many images in private messages?

It would be very helpful to limit at least that.

2 Likes

I’m still experiencing that issue of having too many images in private.

It looks pretty reasonable to be able to limit the number of images one can upload in private messages daily.

Anyone from the team thinks it should be a setting in the core product?

2 Likes

@angus, how time will it take you to create a plugin that adds a single setting to the admin panel like this:

Max number of images one can upload in private messages in 24 hours

We already have some logic in the code that prevents uploading images and shows an error message. For example, when the image is too big and can’t be resized by the system after uploading in a given amount of time, it gets rejected and an error message is shown.

This means we can use the same mechanism of rejecting an image. One hook is needed to the image upload process, with the following logic:

  • if the message is private
  • if the setting is non-empty (and non-zero)
  • make a SQL query to find out how many attachments/images were uploaded in all private messages by the poster in the last 24 hours
  • if the number of images equals to or bigger than the setting value, then reject with an error message

Are you seeing a lot of abusive / bulk PM with lots of image uploads?