Hello josegf!josegf wrote:I created a solution, I hope this helps you.
You'll need PHP 5.5 in your server and PHP GD library. (Probably you have, it's very common config many wordpress theme uses PHP GD library)
Then you need to edit includes/functions_upload.php, locate a function called "move_file"
Before this function you need to add the following code:
then in the move_file function locate the following code:Code: Select all
function resize_image($file, $w, $h, $crop=FALSE) { list($width, $height) = getimagesize($file); $r = $width / $height; if ($crop) { if ($width > $height) { $width = ceil($width-($width*abs($r-$w/$h))); } else { $height = ceil($height-($height*abs($r-$w/$h))); } $newwidth = $w; $newheight = $h; } else { if ($w/$h > $r) { $newwidth = $h*$r; $newheight = $h; } else { $newheight = $w/$r; $newwidth = $w; } } if($this->extension == "jpg") $src = imagecreatefromjpeg($file); if($this->extension == "png") $src = imagecreatefrompng($file); $dst = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); if($this->extension == "jpg") imagejpeg($dst,$file); if($this->extension == "png") imagepng($dst,$file); }
switch ($upload_mode)
just before this insert this code:
And that's allCode: Select all
$this->resize_image($this->filename,$this->upload->max_width,$this->upload->max_height);
P.D. Please if you distribute/post this solution, please just mention me, thanks.
Cheers (ツ)
Jose A. Gallardo
Twitter: @Gallardo4Code
My forum is localhost and the web server that I have the 5.4.16 version of PHP

I can not test as it tried to update the web server to a higher version and Apache no longer worked
