diff options
Diffstat (limited to 'app/helpers/avatars_helper.rb')
-rw-r--r-- | app/helpers/avatars_helper.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 321811a3ca3..7fc4c1a023f 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true module AvatarsHelper - def project_icon(project_id, options = {}) - source_icon(Project, project_id, options) + def project_icon(project, options = {}) + source_icon(project, options) end - def group_icon(group_id, options = {}) - source_icon(Group, group_id, options) + def group_icon(group, options = {}) + source_icon(group, options) end # Takes both user and email and returns the avatar_icon by @@ -110,16 +110,11 @@ module AvatarsHelper private - def source_icon(klass, source_id, options = {}) - source = - if source_id.respond_to?(:avatar_url) - source_id - else - klass.find_by_full_path(source_id) - end + def source_icon(source, options = {}) + avatar_url = source.try(:avatar_url) - if source.avatar_url - image_tag source.avatar_url, options + if avatar_url + image_tag avatar_url, options else source_identicon(source, options) end |