PDA

View Full Version : Need help altering a piece of code


bira
11-18-2001, 05:24 PM
Hi all,

I posted this on vbulletin.com, only later to discover this renewed site :)

Hopefully someone has an idea here with the following:

I would like to alter the code in admin/functions.php
which replaces [img ]xxxx[/ img] with <img scr= > code.

The original code is:


if($dobbimagecode and ($bbuserinfo[userid]==0 or $bbuserinfo[showimages])) {
// do [img ]xxx[ /img]
$bbcode = preg_replace("/(\[)(img)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\5\" border=\"0\" alt=\"\">", $bbcode);
}


What I would like to do is (described in general):


$image_size = getimagesize("-- the URL inbetween the img vbcode --");

if ($image_size[0] > '120') {

$bbcode = preg_replace("/(\[)(img)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<a href=\"\\5\" target=\"_blank\"><img src=\"\\5\" border=\"2\" width=\"120\" alt=\"Click image to view in full size\"></a><br><font face=\"Verdana\" size=1>(Click image for full size)</font><br>", $bbcode);

} else {

$bbcode = preg_replace("/(\[)(img)(])(\r\n)*([^\"".iif($allowdynimg,"","\?\&")."]*)(\[\/img\])/siU", "<img src=\"\\5\" border=\"0\" alt=\"\">", $bbcode);

}


In other words, I want to resize images larger than a certain
width into thumbnails and I know how to do it, except I don't
know how to extract the image's URL for the 'getimagesize' :)

Help would be appreciated. Right now, I'm using the thumbnails
by default, however it is giving a width='120' even to external
smilies which are usually 10 times smaller than that :D

Thanks,

Bira

bira
11-20-2001, 09:32 PM
Anyone? :)

Admin
11-21-2001, 07:45 AM
I'd help, but I have no idea. :o

bira
11-21-2001, 07:48 AM
ok, toda she'anita :D

Admin
11-21-2001, 07:53 AM
ein be'aya! :D

Seriously, I have no idea when it comes to regex.. :(