Improve hint when uploading a too large avatar (#26935)

Fix #26390

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
Lunny Xiao 2023-09-07 21:35:45 +08:00 committed by GitHub
parent a78c2eae24
commit f20e317d6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -681,7 +681,7 @@ choose_new_avatar = Choose new avatar
update_avatar = Update Avatar update_avatar = Update Avatar
delete_current_avatar = Delete Current Avatar delete_current_avatar = Delete Current Avatar
uploaded_avatar_not_a_image = The uploaded file is not an image. uploaded_avatar_not_a_image = The uploaded file is not an image.
uploaded_avatar_is_too_big = The uploaded file has exceeded the maximum size. uploaded_avatar_is_too_big = The uploaded file size (%d KiB) exceeds the maximum size (%d KiB).
update_avatar_success = Your avatar has been updated. update_avatar_success = Your avatar has been updated.
update_user_avatar_success = The user's avatar has been updated. update_user_avatar_success = The user's avatar has been updated.

View file

@ -38,7 +38,7 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error {
defer r.Close() defer r.Close()
if form.Avatar.Size > setting.Avatar.MaxFileSize { if form.Avatar.Size > setting.Avatar.MaxFileSize {
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big")) return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024))
} }
data, err := io.ReadAll(r) data, err := io.ReadAll(r)

View file

@ -146,7 +146,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
defer fr.Close() defer fr.Close()
if form.Avatar.Size > setting.Avatar.MaxFileSize { if form.Avatar.Size > setting.Avatar.MaxFileSize {
return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big")) return errors.New(ctx.Tr("settings.uploaded_avatar_is_too_big", form.Avatar.Size/1024, setting.Avatar.MaxFileSize/1024))
} }
data, err := io.ReadAll(fr) data, err := io.ReadAll(fr)