After mashing buttons for awhile to figure things out, this is what I think is happening:
With a default install, client_max_body_size == max image size kb, images will not be resized.
Increasing client_max_body_size will allow larger uploads, which Discourse will then attempt to resize under the limit set in max image size kb
Despite the description which implies otherwise, max image size kb doesn’t actually limit upload sizes (this is super confusing!)
Upload sizes are solely set with nginx’s client_max_body_size
When resizing, JPEG’s stay JPEG’s with good results
PNG’s are converted to JPG’s with acceptable results
Animated GIF’s stay GIF’s with generally lousy results
Is this all correct? If so, it seems like the sort of thing that should be explained a little better since an out of the box installation doesn’t do any image resizing even though that is a feature many people might want and it isn’t clear at all from available documentation how to enable it.
Hmm, I just looked at nginx.sample.conf on github and it seems that the default for client_max_body_size is now 10 MB rather than 4 MB. Has this always been the case? I don’t recall ever making a change to that file on my install before today.
Hi Sam, going by the description there doesn’t seem to be working for me:
+ max_image_size_kb: “The maximum image upload size in kB. This must be configured in nginx (client_max_body_size) / apache or proxy as well. Images larger than this and smaller than client_max_body_size will be resized to fit on upload.”
+ max_image_megapixels: “Maximum number of megapixels allowed for an image. Images with a higher number of megapixels will be rejected.”
Or at least no resizing seems to be attempted.
I had max_image_size_kb set to 1000kb and an image slightly over that was replaced by a link and followed by text which says (image larger than 1000KB).
I changed the setting to 500kb and the same thing happened.
I haven’t changed client_max_body_size in NGINX as I assume it is at the default (of 4096).
These are on images that are hot linked btw (where I assume if you have download remote images to local checked) it should treat as a standard upload? (If not can we get it to behave the same way please?)
Edit: Ok so uploading directly and the resizing works - yay! So it’s just the remote images that are being fetched that fail. Not sure what behaviour would be ideal tbh, but on first thought I would think the same - those images get resized too.
I think this is a separate feature request. Certainly if you push max image size down to 200k, it totally makes sense to just resize the hotlinked images when we download them. There are thresholds at play, we should not download a 700 gigabyte image just to figure this out, but yeah something could be a bit better.
I agree Sam. I can’t think of any reason why you wouldn’t want downloaded hot linked images to follow the same rules tbh.
I also just discovered that if you change the max image size, that actually has an impact on what file size you end up with - which is really cool! Setting it to 500kb ended up resizing a 1.2mb image to 360kb, setting it to 200kb, resulted with the same file at 118kb (though obviously it is smaller as well).
Edit: Argh, but we get that original problem again - where images that are too large to be resized fail with:
This is the default setting on our forums. I tried to change it to 20000 and it worked (or appeared to stick), but when I went to upload an image/GIF that was 17.2mb I was greeted with this error message:
Can you tell me what path I would go to (commands to enter) in linux, where I can change the “client_max_body_size” in nginx? I’m on a digitalocean droplet.
Does this mean the default will soon be changed from 4096 to 20000?
/var/discourse only has a shared folder in it. I can’t find the file you speak of. My problem is I have a brand new Discourse installation and no image uploads in posts are working at all. Even as admin, I get the error “Sorry, there was an error uploading that file. Please try again.” i have tried over and over and I get the same error.
Error logs shows:
MaxMindDB (/var/www/discourse/vendor/data/GeoLite2-ASN.mmdb) could not be found: No such file or directory @ rb_sysopen - /var/www/discourse/vendor/data/GeoLite2-ASN.mmdb
Is discourse designed to be a “text-only” discussion group? I have upped all the file settings for max upload to insane sizes and I can’t even upload a 7kb graphic.
I am not sure how to rebuild. Guidance please? This is a brand new installation on a VM and I got absolutely no errors. Everything seems to work except for graphics.
I can’t remember, but that’s what I think I did. I have been adding topics to the forum for about two weeks now. When I tried to either drag a graphic in or click the graphic icon, that’s when I get the error. I did have one web directed upgrade that also went smoothly. Perhaps this is a text only product or graphics is a paid option? I can’t seem to find any info on this.
If /var/discourse contains only shared, then you installed some other way and we can’t guess what the problem might be. the best advice is to take a backup and restore it to the new installation.
Far enough. Is there any way for me to make an installation of Discourse without Docker? Ideally, I would like to install the product this time around in an LXC container.
If you don’t want anyone else to use your install you can see the development installations.
If you want your install to work on the internet, you really want to go with the docker install. If you offered me $5000 to do your lxc installation, I’d probably pass.