Okay... I got a problem.
I get a string from a database containing text, let's call it $text. $text contains whole sentences including URLs of images. For example, $text could be: "Hello, this url could be an image http://www.slook.nl/site.gif and I want to have some control here";
Also, $text can contain more than one URL of images.
Now I already figured a way to change the URL in <IMG SRC="http://www.slook.nl/site.gif" BORDER=1> using eregi_replace, but I want more.
I also want to change the image height and width if these exceed a certain size. I know I can use the GetImageSize() function to get the size of an image but how do I incorporate that with the eregi_replace function so it will convert the URL to an image tag AND add the height and width elements?
Something like:
function ResizeFunction($url){
img = GetImageSize($url);
if ($img[0] > 500){
$width = "500";
}
else {
$width = $img[0];
}
return $width;
}
$text = eregi_replace("http://[%a-z0-9/@._\~:\?+\=\&,-]+","<IMG SRC='\1' " . $width = ResizeFunction('\1') . " BORDER=1>",$text);
Anyone got an idea about this?