Skip to content

Commit

Permalink
Merge pull request #429 from shaialon/master
Browse files Browse the repository at this point in the history
Retinize gravatar image size
  • Loading branch information
SachaG committed Sep 26, 2014
2 parents d95733b + b4a811a commit 0e6338e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/gravatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ Gravatar = {
var hash = !!user.email_hash ? user.email_hash : ''; // if hash not available, just pass empty string
var url = protocol + '://www.gravatar.com/avatar/' + hash;

function retinizeSize(size) {
// return the optimal image size for retina display or zoomed in view.
return Math.ceil(size * Math.max(1, window.devicePixelRatio));
}
options.s = retinizeSize(options.s);

var params = _.map(options, function(val, key) { return key + "=" + val;}).join('&');
if (params !== '')
url += '?' + params;

return url;
}
};

0 comments on commit 0e6338e

Please sign in to comment.