Created
November 12, 2012 10:44
-
-
Save thedaviddias/4058599 to your computer and use it in GitHub Desktop.
MOBILE: Image replacement for hi-res devices
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
//Image replacement for hi-res devices | |
function highdpi_init() { | |
var hiRes = window.devicePixelRatio > 1 ? true : false; | |
if (hiRes) { | |
var els = jQuery(".replace-2x").get(); | |
for(var i = 0; i < els.length; i++) { | |
var src = els[i].src | |
src = src.replace(".png", "@2x.png"); | |
src = src.replace(".jpg", "@2x.jpg"); | |
src = src.replace(".gif", "@2x.gif"); | |
els[i].src = src; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment