Skip to content

Instantly share code, notes, and snippets.

@uniquelau
Created March 7, 2013 17:27
Show Gist options
  • Save uniquelau/5109932 to your computer and use it in GitHub Desktop.
Save uniquelau/5109932 to your computer and use it in GitHub Desktop.
Very simple reduction of PictureFill.js - not suitable for production
// var retina = window.devicePixelRatio > 1;
var retina = window.devicePixelRatio > 1;
if (retina) {
// the user has a retina display
// tbh - lets just drop a cookie, and handle this stuff server-side
// document.cookie='HTTP_IS_RETINA=1;path=/'
$(function () {
var images = document.getElementsByTagName("img");
matches = [];
for (var j = 0, jl = images.length; j < jl; j++) {
var media = images[j].getAttribute("data-retina-src");
if (media) {
console.log(images[j]);
images[j].src = media;
}
}
});
}
else {
// the user has a non-retina display
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment