4 def user_image(user, options = {})
5 options[:class] ||= "user_image"
8 if user.image_use_gravatar
9 user_gravatar_tag(user, options)
11 image_tag user.image.url(:large), options
15 def user_thumbnail(user, options = {})
16 options[:class] ||= "user_thumbnail"
19 if user.image_use_gravatar
20 user_gravatar_tag(user, options)
22 image_tag user.image.url(:small), options
26 def user_thumbnail_tiny(user, options = {})
27 options[:class] ||= "user_thumbnail_tiny"
30 if user.image_use_gravatar
31 user_gravatar_tag(user, options)
33 image_tag user.image.url(:small), options
37 def user_image_url(user, options = {})
38 if user.image_use_gravatar
39 user_gravatar_url(user, options)
41 image_url(user.image.url(:large))
45 # External authentication support
48 image_tag "openid_small.png", :alt => t("users.login.openid_logo_alt"), :class => "openid_logo"
51 def auth_button(name, provider, options = {})
53 image_tag("#{name}.png", :alt => t("users.login.auth_providers.#{name}.alt")),
54 auth_path(options.merge(:provider => provider)),
55 :class => "auth_button",
56 :title => t("users.login.auth_providers.#{name}.title")
64 # See http://en.gravatar.com/site/implement/images/ for details.
65 def user_gravatar_url(user, options = {})
66 size = options[:size] || 100
67 hash = Digest::MD5.hexdigest(user.email.downcase)
68 default_image_url = image_url("users/images/large.png")
69 "#{request.protocol}www.gravatar.com/avatar/#{hash}.jpg?s=#{size}&d=#{u(default_image_url)}"
72 def user_gravatar_tag(user, options = {})
73 url = user_gravatar_url(user, options)
75 image_tag url, options