Suggestion: Image resizing

Djinn Effer

Djinn Effer

Frost Gate Guardian

Join Date: Jun 2005

ex-nO, ex-MS, ex-YAY, ex-EnS

W/

Here's a suggestion I've been thinking of... When a picture is too wide for the forum to properly display, the forum should automatically remove the picture and create a thumbnail of it, with the bbcode then linking the thumbnail to the actual picture.

An example thread of pictures too wide, no offense to the author, can be seen here

Here's an example of what I'm talking about:

Inde

Site Contributor

Join Date: Dec 2004

Yeah, something that's been mentioned before. I'll look around Djinn and see what's out there. I know there are some vb hacks for that but I believe I've found something that may work better.

Savio

Savio

Teenager with attitude

Join Date: Jul 2005

Fifteen Over Fifty [Rare]

Good, cause I'm tired of resizing everything myself.

Djinn Effer

Djinn Effer

Frost Gate Guardian

Join Date: Jun 2005

ex-nO, ex-MS, ex-YAY, ex-EnS

W/

You could try something like this, though it hasn't been updated in ages, it seems. ^^

Amity and Truth

Amity and Truth

Jungle Guide

Join Date: Jun 2006

W/N

I wouldn't use a Javascript to do that. It's easier and faster to just use the HTML inherit resize abilities (that's not the finest solution out there but it saves Guru the Bandwith of having to rehost a resized version of the image like it would be with GD/Imagemagick Resizing and the user the hassle to activate javascript).

Maybe try something along these lines here, it's a bit rushed as i'm short on time currently but it should do the job.

Code:
<?
/* Configure your maxsize here. The $image variable SHOULD be in the
sourcecode somewhere but i dont know how 
vBulletin named it. Just rename it in my function.*/

$img_maxwidth = 635;

// array[0] = width, array[1] = height

$img_size = getimagesize ($image);
if ($img_size[0] >= $img_maxwidth)
{
$perc = $img_maxwidth / $img_size[0];
$img_size_width = round($img_size[0] * $perc);
$img_size_height = round($img_size[1] * $perc);

echo "<img src=$image width=\"$img_size_width\" height=\"$img_size_height\">
<br><a href=$image> Image Resized, click here to view original version</a>";
}

else
{
echo "<img src=$image>";
}
?>