Created
May 30, 2011 02:45
-
-
Save ninetwentyfour/998390 to your computer and use it in GitHub Desktop.
Rails Helper that will return a url for a gravatar
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
module GravatarHelper | |
def gravatar_url_for(email, options = {}) | |
options = { :size => '200', :default => 'retro', :rating => 'pg'}.merge(options) | |
size = options[:size] | |
rating = options[:rating] | |
default = options[:default] | |
# create the md5 hash | |
hash = Digest::MD5.hexdigest(email) | |
# compile URL which can be used in <img src="RIGHT_HERE"... | |
image_src = "http://www.gravatar.com/avatar/#{hash}?s=#{size}r=#{rating}&d=#{default}" | |
return image_src | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: