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?
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?