calabiyau Posted April 4, 2007 Share Posted April 4, 2007 <img style="width: 91px; height: 76px" src="images/star.gif" border="1" alt="star" title="star" hspace="1" vspace="1" width="91" height="76" align="left" /> Tricky question for the above line of html. I have a content editor for a blog that outputs this piece of code for inserting an image. However I am trying to have a rich text format export option to export the blog entries and want to replace all the above with a simple tag like <missing image>. So I am looking for something that will take everything between <img and /> and replace it, without affecting any other occurences of things like width, height, etc that occur elsewhere on the page outside the image tage. Anybody have any idea of how this could be done? Quote Link to comment Share on other sites More sharing options...
calabiyau Posted April 4, 2007 Author Share Posted April 4, 2007 And I have tried using strip tags to just get rid of the image tags altogether but it seems to stop all the rest of the content on the blog entry from displaying. Quote Link to comment Share on other sites More sharing options...
fert Posted April 4, 2007 Share Posted April 4, 2007 $text=preg_replace("/<img (.*) \/>/","<missing image>",$text); Quote Link to comment Share on other sites More sharing options...
calabiyau Posted April 4, 2007 Author Share Posted April 4, 2007 Thanks, worked perfectly.I've been avoiding regular expressions like the plague, but I guess it's time to learn! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.