mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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 <i@sourcehut.net>
This commit is contained in:
		@@ -19,8 +19,12 @@ import (
 | 
				
			|||||||
	"code.gitea.io/gitea/modules/setting"
 | 
						"code.gitea.io/gitea/modules/setting"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
 | 
					const (
 | 
				
			||||||
const DefaultAvatarPixelSize = 28
 | 
						// DefaultAvatarClass is the default class of a rendered avatar
 | 
				
			||||||
 | 
						DefaultAvatarClass = "ui avatar vm"
 | 
				
			||||||
 | 
						// DefaultAvatarPixelSize is the default size in pixels of a rendered avatar
 | 
				
			||||||
 | 
						DefaultAvatarPixelSize = 28
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// EmailHash represents a pre-generated hash map (mainly used by LibravatarURL, it queries email server's DNS records)
 | 
					// EmailHash represents a pre-generated hash map (mainly used by LibravatarURL, it queries email server's DNS records)
 | 
				
			||||||
type EmailHash struct {
 | 
					type EmailHash struct {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -647,7 +647,7 @@ func SVG(icon string, others ...interface{}) template.HTML {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Avatar renders user avatars. args: user, size (int), class (string)
 | 
					// Avatar renders user avatars. args: user, size (int), class (string)
 | 
				
			||||||
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, avatars.DefaultAvatarClass, others...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch t := item.(type) {
 | 
						switch t := item.(type) {
 | 
				
			||||||
	case *user_model.User:
 | 
						case *user_model.User:
 | 
				
			||||||
@@ -678,7 +678,7 @@ func AvatarByAction(action *models.Action, others ...interface{}) template.HTML
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
 | 
					// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
 | 
				
			||||||
func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
 | 
					func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTML {
 | 
				
			||||||
	size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
 | 
						size, class := parseOthers(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	src := repo.RelAvatarLink()
 | 
						src := repo.RelAvatarLink()
 | 
				
			||||||
	if src != "" {
 | 
						if src != "" {
 | 
				
			||||||
@@ -689,7 +689,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
 | 
					// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
 | 
				
			||||||
func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
 | 
					func AvatarByEmail(email, name string, others ...interface{}) template.HTML {
 | 
				
			||||||
	size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
 | 
						size, class := parseOthers(avatars.DefaultAvatarPixelSize, avatars.DefaultAvatarClass, others...)
 | 
				
			||||||
	src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
 | 
						src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if src != "" {
 | 
						if src != "" {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user