<div id="image"></div>
<script type="text/javascript">
(function() {
var a = '[legko.username]', b = a.charAt(0), c = ['gif', 'jpg', 'jpeg', 'png'], d = [];
for(var i=0; i<c.length; i++) {
d[i] = new Image();
d[i].alt = '';
d[i].src = '/users/photo/'+b+'/'+a+'_1s.'+c[i];
d[i].onload = function() {
document.getElementById('image').appendChild(this);
}
}
})();
</script>
Попробуйте так.