I search to detect in a string if the content is just a text or if it's an image URL. I base my detection with the filetype, but I don't know how to detect multiple file types…
var wrapper = (content.indexOf(".jpg", ".jpeg", ".gif", ".png", ".bmp") != -1)
? '<img src="' + content + '" />'
: '<span>' + content + '</span>';
I know this syntax for indexOf is wrong, but in an ideal, that's what I search!