Skip to content

Commit

Permalink
Add an options hash to the arguments to gravatar_for and have it use …
Browse files Browse the repository at this point in the history
…:size from that as the size image to request. Pass 200 to it to get a nice big image.
  • Loading branch information
amonat committed May 5, 2012
1 parent bc076d9 commit 1b049de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/helpers/users_helper.rb
@@ -1,9 +1,10 @@
module UsersHelper

# Returns the Gravatar (http://gravatar.com/) for the given user.
def gravatar_for(user)
def gravatar_for(user, options = { size: 50 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png"
size = options[:size]
gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
end
2 changes: 1 addition & 1 deletion app/views/users/show.html.erb
Expand Up @@ -3,7 +3,7 @@
<aside class="span4">
<section>
<h1>
<%= gravatar_for @user %>
<%= gravatar_for @user, size: 200 %>
<%= @user.name %>
</h1>
</section>
Expand Down

0 comments on commit 1b049de

Please sign in to comment.