Unofficial modifications
nieoficjalne modyfikacje for?w phpBB by Przemo

Foreign support - Resize avatar on upload ENG

kidzior - Pon 30 Kwi, 2007
Temat postu: Resize avatar on upload ENG
This mod resizes avatar on upload to size declared by Admin in CP. It saves proportions, but transparency is gone.

Anyway, let's get started:

Wiadomo?? ukryta / Hidden message
Aby zobaczy? wiadomo?? postaw piwo autorowi piwo.
Kod
OPEN
includes/usercp_avatar.php

Find:

if ( $width > 0 && $height > 0 && $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )

Before add:

if ( $width > $board_config['avatar_max_width'] )
{
$resize_to_width = $board_config['avatar_max_width'];
$resize_to_height = $board_config['avatar_max_width'] / $width * $height;
}
else
{
$resize_to_width = $width;
$resize_to_height = $height;
}
if ( $resize_to_height > $board_config['avatar_max_height'] )
{
$resize_to_width = $board_config['avatar_max_height'] / $height * $width;
$resize_to_height = $board_config['avatar_max_height'];
}

if ( $resize_to_width != $width || $resize_to_height != $height )
{
if ( $imgtype == '.jpeg' || $imgtype == '.jpg' )
{
$resized_avatar = imagecreatetruecolor($resize_to_width, $resize_to_height);
$image = imagecreatefromjpeg($avatar_filename);
imagecopyresampled($resized_avatar, $image, 0, 0, 0, 0, $resize_to_width, $resize_to_height, $width, $height);
imagejpeg($resized_avatar, $avatar_filename, 85);
imagedestroy($resized_avatar);
imagedestroy($image);
}
if ( $imgtype == '.gif' )
{
$resized_avatar = imagecreatetruecolor($resize_to_width, $resize_to_height);
$image = imagecreatefromgif($avatar_filename);
imagecopyresampled($resized_avatar, $image, 0, 0, 0, 0, $resize_to_width, $resize_to_height, $width, $height);
imagegif($resized_avatar, $avatar_filename);
imagedestroy($resized_avatar);
imagedestroy($image);
}
if ( $imgtype == '.png' )
{
$resized_avatar = imagecreatetruecolor($resize_to_width, $resize_to_height);
$image = imagecreatefrompng($avatar_filename);
imagecopyresampled($resized_avatar, $image, 0, 0, 0, 0, $resize_to_width, $resize_to_height, $width, $height);
imagepng($resized_avatar, $avatar_filename);
imagedestroy($resized_avatar);
imagedestroy($image);
}
list($width, $height, $type) = @getimagesize($avatar_filename);
}


Save and close file, upload.


Powered by phpBB modified by Przemo © 2003 phpBB Group