Skip to content

Instantly share code, notes, and snippets.

@iotaweb
Created January 2, 2014 22:27
Show Gist options
  • Save iotaweb/8228276 to your computer and use it in GitHub Desktop.
Save iotaweb/8228276 to your computer and use it in GitHub Desktop.
gravatar Image service for AngularJS (uses md5 factory - see other gist)
//! gravatarImageService
.factory('gravatarImageService', function(md5) {
return {
getImageSrc: function(value, size, rating, defaultUrl, secure) {
// convert the value to lower case and then to a md5 hash
var hash = md5.createHash(value.toLowerCase());
var src = (secure ? 'https://secure' : 'http://www') + '.gravatar.com/avatar/' + hash + '?s=' + size + '&r=' + rating + '&d=' + defaultUrl;
return src;
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment