feat: Use gravatar URL for contacts and users if no image available (#1407)
This commit is contained in:
@@ -9,10 +9,13 @@ module Avatarable
|
|||||||
end
|
end
|
||||||
|
|
||||||
def avatar_url
|
def avatar_url
|
||||||
if avatar.attached? && avatar.representable?
|
return url_for(avatar.representation(resize: '250x250')) if avatar.attached? && avatar.representable?
|
||||||
url_for(avatar.representation(resize: '250x250'))
|
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,15 +110,6 @@ class User < ApplicationRecord
|
|||||||
inboxes.where(account_id: Current.account.id)
|
inboxes.where(account_id: Current.account.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
alias avatar_img_url avatar_url
|
|
||||||
def avatar_url
|
|
||||||
if avatar_img_url == ''
|
|
||||||
hash = Digest::MD5.hexdigest(email)
|
|
||||||
return "https://www.gravatar.com/avatar/#{hash}?d=404"
|
|
||||||
end
|
|
||||||
avatar_img_url
|
|
||||||
end
|
|
||||||
|
|
||||||
def administrator?
|
def administrator?
|
||||||
current_account_user&.administrator?
|
current_account_user&.administrator?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user