feat: Use gravatar URL for contacts and users if no image available (#1407)

This commit is contained in:
Sojan Jose
2020-11-13 19:56:30 +05:30
committed by GitHub
parent f275cf8809
commit 563da0e052
2 changed files with 7 additions and 13 deletions

View File

@@ -9,10 +9,13 @@ module Avatarable
end
def avatar_url
if avatar.attached? && avatar.representable?
url_for(avatar.representation(resize: '250x250'))
else
''
return url_for(avatar.representation(resize: '250x250')) if avatar.attached? && avatar.representable?
if [User, Contact].include?(self.class) && email.present?
hash = Digest::MD5.hexdigest(email)
return "https://www.gravatar.com/avatar/#{hash}?d=404"
end
''
end
end