summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2021-12-15 18:18:38 -0800
committerGitHub <noreply@github.com>2021-12-16 10:18:38 +0800
commitcc129d2ca22100fe9c28106d9bc302678651f339 (patch)
treea4fb2c926d501230267d03b09d6a9518a4e54c32 /modules/repository
parente78ee73d712d8d248b9a3a552187d06632000331 (diff)
downloadgitea-cc129d2ca22100fe9c28106d9bc302678651f339.tar.gz
gitea-cc129d2ca22100fe9c28106d9bc302678651f339.zip
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>
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/commits.go3
-rw-r--r--modules/repository/commits_test.go4
2 files changed, 4 insertions, 3 deletions
diff --git a/modules/repository/commits.go b/modules/repository/commits.go
index 8e727c95d0..9ff9a9531b 100644
--- a/modules/repository/commits.go
+++ b/modules/repository/commits.go
@@ -13,6 +13,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
)
@@ -141,7 +142,7 @@ func (pc *PushCommits) AvatarLink(email string) string {
return avatar
}
- size := avatars.DefaultAvatarPixelSize * avatars.AvatarRenderedSizeFactor
+ size := avatars.DefaultAvatarPixelSize * setting.Avatar.RenderedSizeFactor
u, ok := pc.emailUsers[email]
if !ok {
diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go
index 30edf3362e..d01388fe10 100644
--- a/modules/repository/commits_test.go
+++ b/modules/repository/commits_test.go
@@ -124,13 +124,13 @@ func TestPushCommits_AvatarLink(t *testing.T) {
}
assert.Equal(t,
- "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=112",
+ "https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=84",
pushCommits.AvatarLink("user2@example.com"))
assert.Equal(t,
"https://secure.gravatar.com/avatar/"+
fmt.Sprintf("%x", md5.Sum([]byte("nonexistent@example.com")))+
- "?d=identicon&s=112",
+ "?d=identicon&s=84",
pushCommits.AvatarLink("nonexistent@example.com"))
}