mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 12:15:43 +01:00
Fix visibility of org avatars (#17789)
* Fix visibility of org avatar * more clear syntax Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
21f4401f3e
commit
754fdd8f9c
1 changed files with 15 additions and 9 deletions
|
@ -553,18 +553,24 @@ func SVG(icon string, others ...interface{}) template.HTML {
|
||||||
func Avatar(item interface{}, others ...interface{}) template.HTML {
|
func Avatar(item interface{}, others ...interface{}) template.HTML {
|
||||||
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
|
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
|
||||||
|
|
||||||
if user, ok := item.(*models.User); ok {
|
switch t := item.(type) {
|
||||||
src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
case *models.User:
|
||||||
|
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||||
if src != "" {
|
if src != "" {
|
||||||
return AvatarHTML(src, size, class, user.DisplayName())
|
return AvatarHTML(src, size, class, t.DisplayName())
|
||||||
}
|
}
|
||||||
}
|
case *models.Collaborator:
|
||||||
if user, ok := item.(*models.Collaborator); ok {
|
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||||
src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
|
||||||
if src != "" {
|
if src != "" {
|
||||||
return AvatarHTML(src, size, class, user.DisplayName())
|
return AvatarHTML(src, size, class, t.DisplayName())
|
||||||
|
}
|
||||||
|
case *models.Organization:
|
||||||
|
src := t.AsUser().AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||||
|
if src != "" {
|
||||||
|
return AvatarHTML(src, size, class, t.AsUser().DisplayName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return template.HTML("")
|
return template.HTML("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue