Created
January 4, 2014 14:18
-
-
Save xuncheng/8255814 to your computer and use it in GitHub Desktop.
Generates the Gravatar for given user.
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
# Returns the Gravatar (http://gravatar.com) for the given user. | |
def gravatar_for(user, options = {size: 40}) | |
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | |
size = options[:size] | |
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" | |
image_tag(gravatar_url, alt: user.full_name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment