Skip to content

Instantly share code, notes, and snippets.

@thedaviddias
Created November 12, 2012 10:44
Show Gist options
  • Save thedaviddias/4058599 to your computer and use it in GitHub Desktop.
Save thedaviddias/4058599 to your computer and use it in GitHub Desktop.
MOBILE: Image replacement for hi-res devices
//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