#915 ✓resolved
Kelvin Lomberg

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

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.

New-ticket Create new ticket

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

Shared Ticket Bins

People watching this ticket

Tags

Pages