Skip to content

Commit

Permalink
Fix visibility of org avatars (go-gitea#17789)
Browse files Browse the repository at this point in the history
* Fix visibility of org avatar

* more clear syntax

Co-authored-by: Lunny Xiao <[email protected]>
  • Loading branch information
qwerty287 and lunny authored Nov 24, 2021
1 parent 21f4401 commit 754fdd8
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
}

Expand Down

0 comments on commit 754fdd8

Please sign in to comment.