aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/users_helper.rb
blob: 6ebb20fc5860356d3c0c1a4e663b585a9b9239d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module UsersHelper

  def user_gravatar_image_tag(user)
    gravatar_image_tag user.email, :alt => user.name, :class => "preview", :gravatar => { :default => user_default_avatar , :size => 64 }
  end

  def user_default_avatar
    return "#{root_url}#{image_path('icons/user.png')}" if Rails.application.config.relative_url_root.blank?

    relative_url_root = Rails.application.config.relative_url_root.gsub( /\//, '')
    "#{root_url}#{image_path('icons/user.png')}".
      sub( Regexp.new("/#{relative_url_root}/#{relative_url_root}/"), "/#{relative_url_root}/").
      sub( Regexp.new("/#{relative_url_root}//#{relative_url_root}/"), "/#{relative_url_root}/")
  end

end