Version: 1.00, by Dmitriy
Developer Last Online: Dec 2002
Version: 2.2.x
Rating:
Released: 10-16-2002
Last Update: Never
Installs: 24
No support by the author.
Those of you with busy boards know that a lot of times users don't have a clue of how to re-size the
pictures they want to use as avatars.
Someone may want to use a cool pic he has on the hard drive, but the picture size is too big and
user gets error message when trying to upload it as avatar. Many users don't know how to re-size the
picture and they will just give up and nevere upload the avatar.
I was ignoring this for too long, but now I came up with the solution:
This hack will re-size the uploaded avatar on the fly, meaning there are no error messages
when the picture is too large, it will be re-sized automatically before it's inserted into the
database
open the member.php file
find thess lines:
if ($imginfo[0]>$avatarmaxdimension or $imginfo[1]>$avatarmaxdimension) {
@unlink($filename);
eval("standarderror(\"".gettemplate("error_avatarb addimensions")."\");");
}
replace with these lines:
if ($imginfo=@getimagesize($filename)) {
if ($imginfo[0]>$avatarmaxdimension or $imginfo[1]>$avatarmaxdimension) {
exec($cmd, $exec_output, $exec_retval);
if($exec_retval > 0)
{
print "ERROR: exec() error: $exec_output[0]";
}
else
{
print "<P align=\"center\"><b>Image was resized from " . $image_width . "x" .
$image_height . " to $newsize</p>";
}
}
That's all.
Now make sure in your control panel to set a really large max file size in the avatar options because
people may now use any size pictures, so the file size may possibly be over 500K
Don't worry, after the avatar is re-sized, the new file size will be really small.
This hack uses the Mogrify utility from ImageMagick, which is free from imagemagick.org
hmmm ... it's a bummer that I need to specify a bigger file size beforehand for this hack to work ... I keep max avatar file sizes at 7Kb, to discourage people from using those animated GIFs that may fulfill the dimension requirements, but are almost 50Kb+ in size...
I'd REALLY like to implement the attachment code mentioned above... not sure what code to replace in admin/functions.php ...
This?
PHP Code:
if ($extension=="gif" or $extension=="jpg" or $extension=="jpeg" or $extension=="jpe" or $extension=="png" or $extension=="swf") { // Picture file
if ($imginfo=@getimagesize($attachment)) {
if (($maxattachwidth>0 and $imginfo[0]>$maxattachwidth) or ($maxattachheight>0 and $imginfo[1]>$maxattachheight)) {
eval("standarderror(\"".gettemplate("error_attachbaddimensions")."\");");
}
if (!$imginfo[2]) {
eval("standarderror(\"".gettemplate("error_avatarnotimage")."\");");
}
} elseif (!$allowimgsizefailure) {
eval("standarderror(\"".gettemplate("error_avatarnotimage")."\");");
}
}
Dmitriy: I like the idea for resizing attachment images.. is it possible to make the image click-able, lets say I upload an 1280* picture, have it resize to 640* but when the user clicks it they can see the orginal size.. this would be useful.
Originally posted by Okiewan I'd REALLY like to implement the attachment code mentioned above... not sure what code to replace in admin/functions.php ...
This?
PHP Code:
if ($extension=="gif" or $extension=="jpg" or $extension=="jpeg" or $extension=="jpe" or $extension=="png" or $extension=="swf") { // Picture file
if ($imginfo=@getimagesize($attachment)) {
if (($maxattachwidth>0 and $imginfo[0]>$maxattachwidth) or ($maxattachheight>0 and $imginfo[1]>$maxattachheight)) {
eval("standarderror(\"".gettemplate("error_attachbaddimensions")."\");");
}
if (!$imginfo[2]) {
eval("standarderror(\"".gettemplate("error_avatarnotimage")."\");");
}
} elseif (!$allowimgsizefailure) {
eval("standarderror(\"".gettemplate("error_avatarnotimage")."\");");
}
}