<img src='http://site.com/galleries/179606_08.jpg'/>
<img id='img' src='http://site.com/galleries/179606_08.jpg'/>
var img = document.getElementById('img'),
url = img.getAttribute('src');
function getNum (url) {
var parts = url.split('/'),
len = parts.length,
name = parts[len - 1],
num = name.split('_')[1].split('.')[0];
return num;
}
var num = getNum(url);
console.log(num); // 08