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
|
2015-06-04 17:42:43 +01:00
|
|
|
'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)
|
2015-03-24 11:47:59 +00:00
|
|
|
hex = email.present? ? Digest::MD5.hexdigest(email.try :downcase) : ''
|
|
|
|
"https://secure.gravatar.com/avatar/#{}?s=#{size}&r=pg"
|
2012-03-06 18:59:29 +00:00
|
|
|
end
|
|
|
|
end
|