brianlange Posted March 11, 2010 Share Posted March 11, 2010 I have an email popping script that needs to remove embedded images. The images have "cid" in the source attribute like this one. <img width="83" height="95" src= "cid:image002.jpg@01CAC038.74744940" align="left" /> This is what I have so far which seems to work. Any way I can approve upon this? Thanks in advance. $regEx = '/<img[\w\W]+src=[\r\n]?["\']cid[\w\W]+\s(\/>|>)/'; $img = '<img width="83" height="95" src= "cid:image002.jpg@01CAC038.74744940" align="left" />'; $img = preg_replace($regEx, '', $img); Quote Link to comment Share on other sites More sharing options...
thebadbad Posted March 12, 2010 Share Posted March 12, 2010 The way I would go about it: $img = preg_replace('~<img\b[^>]*\bsrc\s?=\s?([\'"])cid:[^\1]*\1[^>]*>~i', '', $img); Quote Link to comment Share on other sites More sharing options...
brianlange Posted March 12, 2010 Author Share Posted March 12, 2010 Awesome, thank you very much. 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.