Created
October 25, 2011 11:44
-
-
Save bytespider/1312426 to your computer and use it in GitHub Desktop.
Replace images with hires versions on iPhone4+
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /> | |
<style> | |
html, body { padding: 0; margin: 0; } | |
</style> | |
</head> | |
<body> | |
<img src="testcardk_320.jpg" data-src="testcardk_640.jpg" width="320"> | |
<script> | |
if (!!window.devicePixelRatio && window.devicePixelRatio > 1) | |
{ | |
var images = document.querySelectorAll("img[data-src]"), | |
length = images.length, | |
i = 0; | |
for (; i < length; ++i) | |
{ | |
images[i].src = images[i].dataset.src; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment