diff options
author | qwerty287 <80460567+qwerty287@users.noreply.github.com> | 2021-11-24 04:51:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 11:51:08 +0800 |
commit | 754fdd8f9c2b1e4e78d507fd414968334cf586fd (patch) | |
tree | 58cbb72fe628059aab9d3857f8eed0c5dcaebec0 | |
parent | 21f4401f3e04885da782d77329dedaa35e820997 (diff) | |
download | gitea-754fdd8f9c2b1e4e78d507fd414968334cf586fd.tar.gz gitea-754fdd8f9c2b1e4e78d507fd414968334cf586fd.zip |
Fix visibility of org avatars (#17789)
* Fix visibility of org avatar
* more clear syntax
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | modules/templates/helper.go | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 8b46ed40ce..aec3596bd4 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -553,18 +553,24 @@ func SVG(icon string, others ...interface{}) template.HTML { func Avatar(item interface{}, others ...interface{}) template.HTML { size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...) - if user, ok := item.(*models.User); ok { - src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor) + switch t := item.(type) { + case *models.User: + src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor) if src != "" { - return AvatarHTML(src, size, class, user.DisplayName()) + return AvatarHTML(src, size, class, t.DisplayName()) } - } - if user, ok := item.(*models.Collaborator); ok { - src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor) + case *models.Collaborator: + src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor) + if src != "" { + return AvatarHTML(src, size, class, t.DisplayName()) + } + case *models.Organization: + src := t.AsUser().AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor) if src != "" { - return AvatarHTML(src, size, class, user.DisplayName()) + return AvatarHTML(src, size, class, t.AsUser().DisplayName()) } } + return template.HTML("") } |