http://www.w3schools.com/jsref/dom_obj_image.aspMime type is not readily available, so this may be wrong. It assumes the file is loaded by name (a JPEG image can be retrieved via query, such as "/get_image?id=x")
var imgs = document.getElementsByTagN
ame('img')
;
var jpg = null;
for(var i=0;i<imgs.length;i++) {
if((imgs[i].src.substr(-5)
.toLower()
== '.jpeg') || (imgs[i].src.substr(-4).to
Lower() == '.jpg')) {
jpg=imgs[i];
break;
}
}