hi all,

i'm having a problem with finding an replacing certain values in strings passed to a message board. basically, i have things set up so users can post videos or images, but i want to limit the dimensions to, say, 400px in width so i don't have everthing shifting around on the page. i can easily do this with the following string replacement method:

$find_width = "/width=\"\d+\"/i";
$max_width = "width=\"400\"";
$replace_width = preg_replace($find_width, $max_width, $string);

what i would like to do, though, is find the original width value and determine if it is over my max value, and if so replace it with the max value. that way smaller images are not scaled up. also i think it would be useful for finding the value of the height and scaling it in proportion to width of the file instead of supplying an arbitary height value and risk stretching the image.