crunch-node/data/static/scripts/crunch.js

15 lines
643 B
JavaScript

function changeImg(e) {
if (e.getAttribute('load') == 'lazy') {
path = '/photos/'+e.getAttribute('slug');
if (window.devicePixelRatio && window.devicePixelRatio > 1) {
console.log('Loading retina version of '+e.getAttribute('slug'));
e.setAttribute('load', 'loaded');
e.src = path+'/'+e.getAttribute('size')+'2x.'+e.getAttribute('ext');
}
else {
console.log('Loading non-retina version of '+e.getAttribute('slug'));
e.setAttribute('load', 'loaded');
e.src = path+'/'+e.getAttribute('size')+'.'+e.getAttribute('ext');
}
}
}