Skip to content

Commit 6117c8b

Browse files
author
Xinyu Zhou
authored
Fix vertical align of committer avatar rendered by email address (#21884) (#21919)
Backport #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` Signed-off-by: Xinyu Zhou <[email protected]>
1 parent ba16df8 commit 6117c8b

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
@@ -19,8 +19,12 @@ import (
1919
"code.gitea.io/gitea/modules/setting"
2020
)
2121

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

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

modules/templates/helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ func SVG(icon string, others ...interface{}) template.HTML {
647647

648648
// Avatar renders user avatars. args: user, size (int), class (string)
649649
func Avatar(item interface{}, others ...interface{}) template.HTML {
650-
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
650+
size, class := parseOthers(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
651651

652652
switch t := item.(type) {
653653
case *user_model.User:
@@ -678,7 +678,7 @@ func AvatarByAction(action *models.Action, others ...interface{}) template.HTML
678678

679679
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
680680
func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
681-
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
681+
size, class := parseOthers(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
682682

683683
src := repo.RelAvatarLink()
684684
if src != "" {
@@ -689,7 +689,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
689689

690690
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
691691
func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
692-
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
692+
size, class := parseOthers(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
693693
src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
694694

695695
if src != "" {

0 commit comments

Comments
 (0)