<img src="path" alt="sometext" title="sometext" id="someId">
var el = document.getElementById("someId");
var foo = {};
for (var att, i = 0, atts = el.attributes, n = atts.length; i < n; i++){
att = atts[i];
foo[att.nodeName] = att.nodeValue
}
console.log(foo);