diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-09-07 21:35:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-07 13:35:45 +0000 |
commit | f20e317d6d2e298a75a1c9d3255a1a7340d4c48d (patch) | |
tree | 445cfaafd19855f97966abeb14ebf3cd6adbe048 | |
parent | a78c2eae243077c1fed5f7b056c64072d3c63ac8 (diff) | |
download | gitea-f20e317d6d2e298a75a1c9d3255a1a7340d4c48d.tar.gz gitea-f20e317d6d2e298a75a1c9d3255a1a7340d4c48d.zip |
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>
-rw-r--r-- | options/locale/locale_en-US.ini | 2 | ||||
-rw-r--r-- | routers/web/repo/setting/avatar.go | 2 | ||||
-rw-r--r-- | routers/web/user/setting/profile.go | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 4f5f0383e9..ea9f6147ae 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -681,7 +681,7 @@ choose_new_avatar = Choose new avatar update_avatar = Update Avatar delete_current_avatar = Delete Current Avatar 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_user_avatar_success = The user's avatar has been updated. diff --git a/routers/web/repo/setting/avatar.go b/routers/web/repo/setting/avatar.go index ae80f1db01..02c807b775 100644 --- a/routers/web/repo/setting/avatar.go +++ b/routers/web/repo/setting/avatar.go @@ -38,7 +38,7 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error { defer r.Close() 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) diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 61089d0947..e1dc5680ca 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -146,7 +146,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * defer fr.Close() 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) |