Upload Image Size Bugs Upload Image Size Bugs
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Upload Image Size Bugs

Started by 406man, December 29, 2024, 11:50:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

406man

Several months back I changed some aspects of my gallery which included changing the maximum image size. What I want is for users to upload images that are a particular height or less. Images are not resized to be sure that what users see is what they uploaded. The gallery config doesn't allow me to set a maximum height and width as it's the maximum height that's important. I have to accept any width. I found that both the 1.6.26 single and multiple upload routines fail to validate the image size properly with this combination of config settings.

In more detail, bug 1 is that if the gallery config settings are:
"Auto resize images that are larger than max width or height" is unchecked
and "Use Dimension" is set to either "Height" or "Width"
... the validation works as if "Use Dimension" is set to "Max Aspect".
This means that if I upload an image that's 1600px wide by 1200px high with:
"Use Dimension" set to "Height"
and "Max width or height for uploaded pictures" set to 1200px
...it's rejected because the validation rejects an image that's wider than 1200px. It should ignore the width.
The bug is present when using both the single upload and h5 multiple upload methods.
To fix the bug I've created a new version of picmgmt.inc.php with additional code for a config where images are not resized.

Bug 2 is that the error message that's displayed by the single image uploader when an image is rejected due to being too big is displayed on an ugly blank white screen, not on a proper CPG screen. The error message displayed by the h5 multiple upload is fine.
To fix the bug I've created a new version of uniload.php which has a new section for handling an error in the single upload method. It redirects to the upload screen with a message box showing the error. To avoid having to update the language files the error message for a width that is too large isn't ideal in my updated version and says:
 "The size of file you have uploaded is too large (maximum allowed is Height x 1200)!';

Ideally the error message text in english.php would be changed to:
'The file you have uploaded is too large. Should be: %s  %s px'
...which after substitution looks like:
'The file you have uploaded is too large. Maximum: Height 1200 px'

For reference, the error variable is, in english.php:
$lang_db_input_php['err_fsize_too_large'] = 'The size of file you have uploaded is too large (maximum allowed is %s x %s)!';
Ideally the updated variable would be:
$lang_db_input_php['err_fsize_too_large'] = 'The file you have uploaded is too large. Maximum: %s  %s px'

These changes have been working successfully for several months.

Revised versions of picmgmt.inc.php and uniload.php attached. As the forum doesn't allow me to upload a .php file I've added .txt as a file extension. I haven't changed english.php to avoid any conflicting edits with other changes.

I'm not asking for any support, only to include the fixes in the next release of CPG.