Last active
December 15, 2015 18:48
-
-
Save andreypronin/5306048 to your computer and use it in GitHub Desktop.
Using gravatar in rails. Taken from http://stackoverflow.com/questions/770876/how-do-i-add-gravatar-identicons-into-ruby-on-rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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