Profile.php
Find
// Now check the width/height
if (empty($width) || empty($height) || $width > $forum_config['o_avatars_width'] || $height > $forum_config['o_avatars_height'])
{
@unlink($forum_config['o_avatars_dir'].'/'.$id.'.tmp');
$errors[] = sprintf($lang_profile['Too wide or high'], $forum_config['o_avatars_width'], $forum_config['o_avatars_height']);
}
else if ($type == 1 && $uploaded_file['type'] != 'image/gif') // Prevent dodgy uploads
{
@unlink($forum_config['o_avatars_dir'].'/'.$id.'.tmp');
$errors[] = $lang_profile['Bad type'];
}
Replace by
// Now check the width/height
list($width, $height, $type,) = getimagesize($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
if (empty($width) || empty($height) || $width > $forum_config['o_avatars_width'] || $height > $forum_config['o_avatars_height'])
{
// Attempt to resize if GD is installed with support for the uploaded image type, as well as JPG for the output
$check_type = str_replace(array(1, 2, 3), array('IMG_GIF', 'IMG_JPG', 'IMG_PNG'), $type);
if (extension_loaded('gd') && imagetypes() & constant($check_type) && imagetypes() & IMG_JPG)
{
// Load the image for processing
if ($type == 1) $src_img = @imagecreatefromgif($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
elseif ($type == 2) $src_img = @imagecreatefromjpeg($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
elseif ($type == 3) $src_img = @imagecreatefrompng($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
if ($src_img)
{
// Figure out new image dimensions based on the maximum width
$new_w = $forum_config['o_avatars_width'];
$ratio = $height * $new_w;
$new_h = $ratio / $width;
// Do the new dimensions, based on the maximum width, fit the maximum height? If not, recalculate
if ($new_h > $forum_config['o_avatars_height'])
{
$new_h = $forum_config['o_avatars_height'];
$ratio = $width * $new_h;
$new_w = $ratio / $height;
}
// Resize the image
$new_img = imagecreatetruecolor($new_w, $new_h);
imagecopyresampled($new_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, $width, $height);
// Delete the old image and write the newly resized one
@unlink($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
imagejpeg($new_img,$base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp',85);
// Set the extension to JPG, since that's what the resized image is now
$extensions[0] = '.jpg';
}
// Something went wrong while attempting to load the image for processing
else
{
@unlink($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
message('An unexpected error occured while attempting to resize the image.');
}
}
// No GD installed or image type not supported; can't resize
else
{
@unlink($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
message($lang_profile['Too wide or high'].' '.$forum_config['o_avatars_width'].'x'.$forum_config['o_avatars_height'].' '.$lang_profile['pixels'].'.');
}
}
else if ($type == 1 && $uploaded_file['type'] != 'image/gif') // Prevent dodgy uploads
{
@unlink($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp');
message($lang_profile['Bad type']);
}
// Make sure the file isn't too big
if (filesize($base_url.'/'.$forum_config['o_avatars_dir'].'/'.$id.'.tmp') > $forum_config['o_avatars_size'])
message($lang_profile['Too large'].' '.$forum_config['o_avatars_size'].' '.$lang_profile['bytes'].'.');
Find
// Make sure the file isn't too big
if ($uploaded_file['size'] > $forum_config['o_avatars_size'])
$errors[] = sprintf($lang_profile['Too large'], forum_number_format($forum_config['o_avatars_size']));
Delete it
include/functions.php
Find
$avatar_markup = '<img src="'.$base_url.'/'.$path.'" width="'.$avatar_width.'" height="'.$avatar_height.'" alt="'.$alt_attr.'" />';
Replace by
$avatar_markup = '<img src="'.$base_url.'/'.$path.'" alt="'.$alt_attr.'" />';
If you get
The server was unable to save the uploaded file.
error, chmod /img/avatars/ folder.
Now you set maxsize ( avatars would be resized to it ) in Settings -> Features