Skip to content

Instantly share code, notes, and snippets.

@sandywu
Created February 25, 2014 11:48
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 sandywu/9207474 to your computer and use it in GitHub Desktop.
Save sandywu/9207474 to your computer and use it in GitHub Desktop.
define(['zepto'], function() {
function getDevicePixelRatio() {
return window.devicePixelRatio ? window.devicePixelRatio : 1;
}
function getImageSize() {
if(window.__NETWORK_STATUS__ == 3) {
return "_80x80Q90.jpg";
}
var dpr = Number(getDevicePixelRatio());
if (dpr == 1) {
return "_120x120Q90.jpg";
} else if (dpr == 1.5 || dpr == 1.3) {
return "_180x180Q90.jpg";
} else if (dpr >= 2) {
return "_240x240Q90.jpg";
}
}
return {
'getImageSize': getImageSize
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment