Iam getting data from mysql table, from the a field of type: text.. i want to search that string for , and not replace it with an image at once.. I want to do following:
See if the image exits
If it does, check the image type(jpg,gif accepted types)
check the image ratio(height/width), and adjust if necasarry
NOW, replace the [IMG], with the new information, including the new width and height [/list=1]
Anyone have any ideas to how I can think on this issue? earlier I used:
$text = preg_replace("/[IMG](.*)[\/IMG]/", "<img src=\"\1\" alt=\"\" border=\"0\" style=\"display:block;\">", $text);
to replace a image, but it sucks with large images..
Any ideas??
Use preg_replace with the /e modifier, or preg_replace_callback, and put steps 1..4 in a function. The latter, for preference, and just return the string unchanged if the steps fail.