This is actually great, except as others mentioned it breaks attachment upload. But there is a simple solutionjosegf 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
Code: Select all
global $user, $phpbb_root_path, $mode;
Code: Select all
if ($mode == 'avatar') { $this->resize_image($this->filename,$this->upload->max_width,$this->upload->max_height); }
Scroll to the bottom:designer2k2 wrote: ↑Wed Jan 04, 2017 3:55 pmHello,
how does this apply for 3.2?
there is no includes/functions_upload.php anymore...
Hi Anvar,