|
Thanks for your replies. I looked in to the DOM and the native BBCode extension, but I found them too big to dig into just for this small, one-time application. And I'd prefer not to drag a big framework like Pear into this, again, just for this small application.
Nevertheless, after several hours of trial and error I managed to get it working just the way I wanted using some regex functions. I used preg_replace_callback() with the pattern "|<img[^>]*>|i" to find all <img> tags, and a callback function in which I used preg_find_all() with the pattern "|([a-z]+)=\"[^\"]*\"|i" to find all attributes. I went through all the attributes and stripped away those that I will not allow and also checked the src attribute, to see if it points to a local file. And if it doesn't I'll return and empty string which will then replace the entire <img> tag.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
Last edited by lizciz; 07-11-2011 at 07:43 PM..
Reason: Typo
|