Skip to content

Commit e483ec3

Browse files
author
Xinyu Zhou
authored
Fix vertical align of committer avatar rendered by email address (#21884)
Committer avatar rendered by `func AvatarByEmail` are not vertical align as `func Avatar` does. - Replace literals `ui avatar` and `ui avatar vm` with the constant `DefaultAvatarClass`
1 parent a3c09fb commit e483ec3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

models/avatars/avatar.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ import (
2020
"code.gitea.io/gitea/modules/setting"
2121
)
2222

23-
// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
24-
const DefaultAvatarPixelSize = 28
23+
const (
24+
// DefaultAvatarClass is the default class of a rendered avatar
25+
DefaultAvatarClass = "ui avatar vm"
26+
// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
27+
DefaultAvatarPixelSize = 28
28+
)
2529

2630
// EmailHash represents a pre-generated hash map (mainly used by LibravatarURL, it queries email server's DNS records)
2731
type EmailHash struct {

modules/templates/helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ func AvatarHTML(src string, size int, class, name string) template.HTML {
607607

608608
// Avatar renders user avatars. args: user, size (int), class (string)
609609
func Avatar(item interface{}, others ...interface{}) template.HTML {
610-
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar vm", others...)
610+
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
611611

612612
switch t := item.(type) {
613613
case *user_model.User:
@@ -638,7 +638,7 @@ func AvatarByAction(action *activities_model.Action, others ...interface{}) temp
638638

639639
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
640640
func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
641-
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar", others...)
641+
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
642642

643643
src := repo.RelAvatarLink()
644644
if src != "" {
@@ -649,7 +649,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
649649

650650
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
651651
func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
652-
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, "ui avatar", others...)
652+
size, class := gitea_html.ParseSizeAndClass(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
653653
src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
654654

655655
if src != "" {

0 commit comments

Comments
 (0)