Created
March 7, 2013 17:27
-
-
Save uniquelau/5109932 to your computer and use it in GitHub Desktop.
Very simple reduction of PictureFill.js - not suitable for production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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