Fixed Attachments not resizing as expected to option limits

bobs409

Active member
I have my forum's attachment file size limit set at 150kb maximum and the image size set to 700 pixels width and 600 pixels in height.

Prior to the update to 2.0, this would allow any picture file up to 150kb's to be attached and it would re-size the picture down within the 700 x 600 setting. It is no longer doing that, now the attached picture has to actually be within the 700 x 600 size or it fails to upload.

Is there a reason for this change or is a bug?

I really liked the way it worked prior as a lot of my users are older and don't know how to resize a .jpg and the forum would do that for them. (as long as the picture was 150kbs or smaller) In doing so, this would also reduce the actual file size which helped save server space.

I hope we can get this back the way it was.


Thanks,

Bob
 
It still functions that way and you should be able to confirm that here. Do you have a test file that you can upload so we can confirm the issue? How big is the image, in both file size and dimensions?

It's possible that the file is being resized but still above the 150KB limit, which is quite restrictive. I believe XF1 would behave the same way though.
 
This first pic is the one that would not upload with my setting mentioned above: (480 x 640) 70.1kbs

5115.webp

I then rotated it and saved it like below. That one did upload. (640 x 480) 70.3kbs

5115b.webp

Instead of resizing a picture down to 700 x 600, I guess now it's using those as limits so now it will reject anything larger. Before it would not do that. Hope that makes sense. :D
 
This was a bug, which I've now fixed for 2.0.2. It was specific to using different width and height limits. There are two changes to properly fix this, both in src/XF/Images/AbstractDriver.php.

First, change:
Code:
if ($this->width < $width && $this->height < $width && !$upsize)
to:
Code:
if ($this->width < $width && $this->height < $height && !$upsize)
And then change:
Code:
$newRatio = ($width / $width);
to:
Code:
$newRatio = ($width / $height);
 
Top Bottom