Skip to content

Instantly share code, notes, and snippets.

@aqualungdesign
Created February 6, 2013 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqualungdesign/4722549 to your computer and use it in GitHub Desktop.
Save aqualungdesign/4722549 to your computer and use it in GitHub Desktop.
js for retina display
var retina = function(){
if (window.devicePixelRatio === 2) {
var images = $("img.hires");
// loop through the images and make them hi-res
for(var i = 0; i < images.length; i++) {
// create new image name
var imageType = images[i].src.substr(-4);
var imageName = images[i].src.substr(0, images[i].src.length - 4);
imageName += "@2x" + imageType;
//rename image
images[i].src = imageName;
}
}
};
retina();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment