Bug: Auto resize sometimes doesn't work
Reported by Kelvin Lomberg | February 11th, 2013 @ 10:52 PM | in 2.1.2 (closed)
There's a couple of related issues I found here.
Firstly the fix from #902 didn't seem to work for me. I found you can't specify both image_ratio_y = true and image_ratio_no_zoom_in = true. You also need to specify an image_y input as the maximum height for the image otherwise it doesn't seem to work either. This could be set to the same as the maximum width so really it will be a max dimension rather than max width.
The second issue I had only seemed to happen on my production server. The upload class couldn't detect the mime type and because it was using a temporary file there was no extension so it couldn't use that to guess the mime type. To fix this I just moved the uploaded file first so it had an extension on it. My code now looks like:
$tempFile = tempnam(sys_get_temp_dir(), 'exp_upload_') . $_destFile;
move_uploaded_file($_FILES[$_postName]['tmp_name'], $tempFile);
require_once(BASE . 'framework/modules/pixidou/includes/class.upload/class.upload.php');
$handle = new upload($tempFile);
if ($handle->uploaded) {
$handle->file_new_name_body = $_destFile;
$handle->file_new_name_ext = '';
$handle->image_resize = true;
$handle->image_ratio = true;
$handle->image_x = $maxwidth;
$handle->image_y = $maxwidth;
$handle->image_ratio_no_zoom_in = true;
$handle->process(BASE . $_destDir);
Comments and changes to this ticket
-
expNinja February 12th, 2013 @ 02:44 AM
- State changed from new to resolved
(from [71de9ff6daa400f96d77a3e479b504c5cb56abc7]) Uses a better algorithm to make sure we know the mimetype and only downsize images on upload if requested [#915 state:resolved] https://github.com/exponentcms/exponent-cms/commit/71de9ff6daa400f9...
-
expNinja February 12th, 2013 @ 02:53 AM
(from [575a05b333694fa748e2c4c76dcd3b76f21ce973]) Uses a better algorithm to make sure we know the mimetype and only downsize images on upload if requested #915 state:resolved https://github.com/exponentcms/exponent-cms/commit/575a05b333694fa7...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Bug Tracker for Exponent CMS