The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Auto resizing of avatars Details »» | |||||||||||||||||||||||||
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) { $image_width = $imginfo[0]; $image_height= $imginfo[1]; if ($image_height > $image_width) { $sizefactor = (double) ($avatarmaxdimension / $image_height); } else { $sizefactor = (double) ($avatarmaxdimension / $image_width) ; } $newwidth = (int) ($image_width * $sizefactor); $newheight = (int) ($image_height * $sizefactor); $newsize = $newwidth . "x" . $newheight; $cmd = "/usr/local/bin/mogrify -resize $newsize "."$filename 2>&1"; 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 I have this hack installed on www.examnotes.net/forums You need at least 1 post in order to upload avatar. Show Your Support
|
Comments |
#22
|
||||
|
||||
have the boards gone dead no hacker wants to help anymore
even where it says the hacker agreed to give help Lol infact the ones that say cannot guarantee help seem to helping more these days :P |
#23
|
|||
|
|||
PHP SAFE MODE MUST BE OFF TO USE THIS HACK. ELSE IT' WON'T WORK
|
#24
|
|||
|
|||
It doesn't work with 2.3.0, does it? I got parse error.
Parse error: parse error, unexpected '}' in /home/somewhere/public_html/vb/admin/functions.php on line 1829 Imagemagick installed, safe upload mode off. |
#25
|
|||
|
|||
check your code....remove 1 extra "}"
it should work i found another bug....if a gif dimension is smaller than avatarmaxdimension in setting then this hack will not run. and the size will not change forexample a user have a gif avatar with size 1mb and dimension is smaller than the one i specified in setting than he will be able to upload his avatar.... so u need to change the code in admin/functions.php |
#26
|
|||
|
|||
I'm running linux on my server, and they're saying they support everything except some, but as you'd suppose. Linux isnt there!
|
#27
|
||||
|
||||
any updates on this would be great
|
#28
|
|||
|
|||
I don't have ImageMagick, but we do have GD v2 installed. PhotoPost uses GD2 to resize jpeg images. This appears to be the line you're using to resize the image.
Code:
$cmd = "/usr/local/bin/mogrify -resize $newsize "."$attachment 2>&1"; |
#29
|
|||
|
|||
Quote:
|
#30
|
|||
|
|||
Looks like this seems to work , but on either part you use it says it makes the image smaller but when you look at the image , it is the same size as before ,
Post a attachment on forums and it says image has been resized, but it don't work. could this be in imagemajicK not set right??? even the avatar part works the same, so unlees its something to do with the vb admin settings then it has to be in the imagemajicK setting I would think..... |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|