Skip to content

Commit f20e317

Browse files
lunnydelvhwxiaoguangGiteaBotsilverwind
authored
Improve hint when uploading a too large avatar (#26935)
Fix #26390 --------- Co-authored-by: delvh <[email protected]> Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: Giteabot <[email protected]> Co-authored-by: silverwind <[email protected]>
1 parent a78c2ea commit f20e317

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ choose_new_avatar = Choose new avatar
681681
update_avatar = Update Avatar
682682
delete_current_avatar = Delete Current Avatar
683683
uploaded_avatar_not_a_image = The uploaded file is not an image.
684-
uploaded_avatar_is_too_big = The uploaded file has exceeded the maximum size.
684+
uploaded_avatar_is_too_big = The uploaded file size (%d KiB) exceeds the maximum size (%d KiB).
685685
update_avatar_success = Your avatar has been updated.
686686
update_user_avatar_success = The user's avatar has been updated.
687687

routers/web/repo/setting/avatar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error {
3838
defer r.Close()
3939

4040
if form.Avatar.Size > setting.Avatar.MaxFileSize {
41-
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big"))
41+
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024))
4242
}
4343

4444
data, err := io.ReadAll(r)

routers/web/user/setting/profile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
146146
defer fr.Close()
147147

148148
if form.Avatar.Size > setting.Avatar.MaxFileSize {
149-
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big"))
149+
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024))
150150
}
151151

152152
data, err := io.ReadAll(fr)

0 commit comments

Comments
 (0)