I use a regex convert <a>
with images url to <img>
var message='<a href="http://example.com/example.jpg" target="_blank" rel="noopener noreferrer">http://example.com/example.jpg</a>';
message.replace(/<a.*>(https?:\/\/.*\.(?:png|jpg))<\/a>/gi,'<img src="$1">');
console.log(message);
//expect: <img src="http://example.com/example.jpg">