To remove any img tag that does not contain a src attribute:
$str = preg_replace('#<img\s((?!src=).)/?>#Umi','',$str); </code> </pre> This is shorter and, I think, more reliable.
To remove any img tag that does not contain a src attribute: