Skip to content

Instantly share code, notes, and snippets.

@andreypronin
Last active December 15, 2015 18:48
Show Gist options
  • Save andreypronin/5306048 to your computer and use it in GitHub Desktop.
Save andreypronin/5306048 to your computer and use it in GitHub Desktop.
def gravatar_for email, options = {}
options = {:alt => 'avatar', :class => 'avatar', :size => 80}.merge! options
id = Digest::MD5::hexdigest email.strip.downcase
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?s=' + options[:size].to_s
options.delete :size
image_tag url, options
end
# Using identicons etc through gravatar (see http://en.gravatar.com/site/implement/images/)
id = Digest::MD5::hexdigest email.strip.downcase
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?f=y&d=wavatar' # wavatar
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?f=y&d=identicon' # identicon
url = 'http://www.gravatar.com/avatar/' + id + '.jpg?f=y&d=monsterid' # monsterid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment