Well I have this thing almost working, the problem is when it tries to put the images back into the content. It has a preq_replace error, that I can't find so if someone could help me out here that would be great.
Here is the full code for this:
CODE
<?php
function thumb($src){
list($width, $height, $type, $attr) = getimagesize($src);
if($width>=400){
$divW = $width/200;
$width = $width/$divW;
$height = $height/$divW;
}
elseif($height>=600){
$divH = $h/400;
$height = $height/$divH;
$width = $width/$divH;
}
else{
}
return '<a href="' . $src . '"><img src="' . $src . '" width="' . $width . '" height="' . $height . '"></a>';
}
$img;
$teststr="This is some test: <img src='http://www.reigninggames.com/forum_images/banner2.png'><br><br>This is some more text: <img src='http://www.reigninggames.com/forum_images/banner2.png'>";
$img = preg_replace( "/\<img src='(.*?)\'\>/ims", "}>\\1,<{", $teststr);
$img = '<{' . $img . '}>';
$img = preg_replace( "/\<{(.*?)\}\>/ims", "", $img);
$images = explode(',', $img);
echo'<br><br><br>';
krsort($images);
$imageNum=0;
foreach($images AS $num => $url){
if($imageNum==0){
}
else{
$thumbimg[$num] = thumb($url);
}
$imageNum++;
}
foreach($thumbimg AS $num => $code){
//LINE 63
$content = preg_replace( "/\ <img src='$images[$num]'\>/ims", $code, $teststr);
}
echo $content;
echo'<br><br><br>Testing number 1';
$testa='http://www.reigninggames.com/forum_images/banner2.png';
echo thumb($testa);
?>