mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Make AvatarRenderedSizeFactor configurable and set it to 3 (#17951)
Save a bit of bandwidth by only requesting 3-times the rendered avatar size. Factor 4 is only really beneficial on a handful of mobile phones and I don't think they are the primary device we design for. Configurability contributed by zeripath. Fixes: https://github.com/go-gitea/gitea/pull/17422 Fixes: https://github.com/go-gitea/gitea/issues/16287 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -557,17 +557,17 @@ func Avatar(item interface{}, others ...interface{}) template.HTML {
|
||||
|
||||
switch t := item.(type) {
|
||||
case *user_model.User:
|
||||
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||
src := t.AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
|
||||
if src != "" {
|
||||
return AvatarHTML(src, size, class, t.DisplayName())
|
||||
}
|
||||
case *models.Collaborator:
|
||||
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||
src := t.AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
|
||||
if src != "" {
|
||||
return AvatarHTML(src, size, class, t.DisplayName())
|
||||
}
|
||||
case *models.Organization:
|
||||
src := t.AsUser().AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
|
||||
src := t.AsUser().AvatarLinkWithSize(size * setting.Avatar.RenderedSizeFactor)
|
||||
if src != "" {
|
||||
return AvatarHTML(src, size, class, t.AsUser().DisplayName())
|
||||
}
|
||||
@@ -596,7 +596,7 @@ func RepoAvatar(repo *repo_model.Repository, others ...interface{}) template.HTM
|
||||
// AvatarByEmail renders avatars by email address. args: email, name, size (int), class (string)
|
||||
func AvatarByEmail(email string, name string, others ...interface{}) template.HTML {
|
||||
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
|
||||
src := avatars.GenerateEmailAvatarFastLink(email, size*avatars.AvatarRenderedSizeFactor)
|
||||
src := avatars.GenerateEmailAvatarFastLink(email, size*setting.Avatar.RenderedSizeFactor)
|
||||
|
||||
if src != "" {
|
||||
return AvatarHTML(src, size, class, name)
|
||||
|
Reference in New Issue
Block a user