Ryan J. Bonnell - 23 May 2008 12:25 PM
I’m having an issue with File 3.1.1 and ExpressionEngine 1.6.3 where the “Resize Images” setting isn’t honored and resets itself to “Auto” every time I update/save the preferences at “CP Home > Admin > Section Administration > File Upload Preferences”.
When this happens, the File extension generates a resized thumbnail for every image uploaded (due to the Auto resizing selected).
I’d like to have the File extension honor my “Resize Images” setting of “None” so that I don’t needlessly have thumbnails generated (since I don’t need them for my specific application).
The server is a RHEL 4 machine with Apache 2.0.52 and PHP Version 4.3.9. I’ve confirmed this behavior on two different installations of ExpressionEngine (on two separate servers).
Is anyone else having the same problem or know of a resolution and/or work-a-round?
I just has this exact problem in File v3.1.1 too.
After looking through the code I found two issues in ext.mh_file_ext.php:
1. At line 403 of ext.mh_file_ext.php the code is:
$r.= '<option'.(($this->resize_images=='no')?' selected="selected"':'').' value="no">Do not resize</option>';
this should be changed to:
$r.= '<option'.(($this->resize_images===FALSE)?' selected="selected"':'').' value="no">Do not resize</option>';
The reason for this is that the _set_prefs() function resets any string parameters of ‘yes’/‘no’ to TRUE/FALSE
This happens on line 458-459.
$value = ($value === 'yes')?TRUE:$value;
$value = ($value === 'no')?FALSE:$value;
This fixes the problem of the file upload preferences page not displaying the correct value for the “Resize Images” field when it has previously been set to “Do not resize”
2. At line 896 of ext.mh_file_ext.php (the “Resize Images” section) the code is:
if($this->resize_images !== FALSE && $file_field['max_width'] != '' || $file_field['max_height'] != '')
this should be changed to:
if($this->resize_images !== FALSE && ($file_field['max_width'] != '' || $file_field['max_height'] != ''))
Brackets must enclose the or ( || ) section of this if statement, otherwise it will pass even when resize_images is set to FALSE.