Skip to content

Commit c844c4f

Browse files
author
Xinyu Zhou
authored
Fix vertical align of committer avatar rendered by email address (#21884) (#21918)
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 f4ec03a commit c844c4f

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
@@ -646,7 +646,7 @@ func SVG(icon string, others ...interface{}) template.HTML {
646646

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

651651
switch t := item.(type) {
652652
case *user_model.User:
@@ -677,7 +677,7 @@ func AvatarByAction(action *activities_model.Action, others ...interface{}) temp
677677

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

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

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

694694
if src != "" {

0 commit comments

Comments
 (0)