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:[email protected]" 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:[email protected]" align="left" />'; $img = preg_replace($regEx, '', $img); Link to comment https://forums.phpfreaks.com/topic/194945-removing-embedded-images-in-mail-script/ 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); Link to comment https://forums.phpfreaks.com/topic/194945-removing-embedded-images-in-mail-script/#findComment-1025039 Share on other sites More sharing options...
brianlange Posted March 12, 2010 Author Share Posted March 12, 2010 Awesome, thank you very much. Link to comment https://forums.phpfreaks.com/topic/194945-removing-embedded-images-in-mail-script/#findComment-1025265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.