I would go with a cleaner solution - no slice/indexOf or anything like that involved: It tests all elements of the ext array against the content and returns the elements, which match. Since there should be only one match, you just need to check the first element.
var content = "/test.png",
ext = [".jpg", ".jpeg", ".gif", ".png", ".bmp"],
res,wrapper;
res = ext.filter(function(el){return content.match(el)});
wrapper = res[0] ? '<img src="'+content+'" />' : '<span>'+content+'</span>';
See Array.prototype.filter on MDN for more explanation. As with Fabrizio's solution this solution might break too, if you have filenames with several .
/test.png.jpg
(whatever the reason for that might be).