PDA

View Full Version : Restrict image size, Don't stretch tables!


Nomb
02-25-2003, 05:17 PM
Many attempts have been made at creating a hack like this and I've tried them all and none of them just resize the image onlyif if it's over a certain size.

I thought I'd use the getimagesize function to accomplish this. I don't want any images with a width of over 550 pixels showing in my postbits. Well, I want to show them, but I want them resized proportionately with a width of 550. Here's what I've done in functions.php and I'm getting a parse error:


if($dobbimagecode and ($bbuserinfo[userid]==0 or $bbuserinfo[showimages])) {
// do [img.]xxx[/img.]
$imginforesize=@getimagesize(\\2);
if($imginforesize[0]>550) {
$height = "height=\"((550 / $imginforesize[0]) * $imginforesize[1])\"";
$bbcode = preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU", "<img src=\"\\2\" border=\"0\" alt=\"\" width=\"550\" $height>", $bbcode);
} else {
$bbcode = preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\(\)\"".iif($allowdynimg,"","!\*\?\&")."]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU", "<img src=\"\\2\" border=\"0\" alt=\"\">", $bbcode);
}
$bbcode = preg_replace("/\[img\](\r\n|\r|\n)*((http|https):\/\/([^;<>\*\(\)\"]+)|[a-z0-9\/\\\._\- ]+)\[\/img\]/siU", "<a href=\"\\2\" target=\"_blank\">\\2</a>", $bbcode);

$bbcode=str_replace("\\'", "'", $bbcode);


Anyone see my mistake here?

Erwin
02-25-2003, 10:37 PM
Are you missing } right at the bottom to close the first if { ?

Freddie Bingham
02-25-2003, 10:59 PM
Do you realize how much you are going to slow your forum down if you call getimagesize on remote images? Not to mention the bandwidth involved in transferring images for every view of showthread.

colicab-d
02-25-2003, 11:45 PM
id love to see this but i think overgrow has a great version of this working for them