2012-03-06 18:59:29 +00:00
|
|
|
module UsersHelper
|
2012-03-11 17:06:41 +00:00
|
|
|
|
|
|
|
def avatar_url_by_email(email, size = :small)
|
2014-01-21 04:51:49 +00:00
|
|
|
avatar_url(User.where(email: email).first || User.new(email: email), size)
|
2012-03-11 17:06:41 +00:00
|
|
|
end
|
|
|
|
|
2012-10-03 17:38:42 +01:00
|
|
|
def avatar_url(subject, size = :small)
|
|
|
|
if subject.try('avatar?')
|
|
|
|
subject.avatar.url(size)
|
|
|
|
elsif subject.kind_of? Group
|
|
|
|
image_path('ava-big.png')
|
2012-03-06 18:59:29 +00:00
|
|
|
else
|
2013-04-02 16:14:32 +01:00
|
|
|
gravatar_url(subject.email, User::AVATAR_SIZES[size])
|
2012-03-06 18:59:29 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def gravatar_url(email, size = 30)
|
|
|
|
"https://secure.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}?s=#{size}&r=pg"
|
|
|
|
end
|
|
|
|
end
|