Add cropping support when modifying the user/org/repo avatar (#33498)
Fixed #33321 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
943cc4f989
commit
40426addfa
11 changed files with 35 additions and 28 deletions
|
@ -195,8 +195,7 @@
|
|||
</div>
|
||||
|
||||
<div class="inline field tw-pl-4">
|
||||
<label for="avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
|
||||
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
|
||||
{{template "shared/avatar_upload_crop" dict "LabelText" (ctx.Locale.Tr "settings.choose_new_avatar")}}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
|
|
@ -89,10 +89,8 @@
|
|||
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
|
||||
{{.CsrfTokenHtml}}
|
||||
<div class="inline field">
|
||||
<label for="avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
|
||||
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
|
||||
{{template "shared/avatar_upload_crop" dict "LabelText" (ctx.Locale.Tr "settings.choose_new_avatar")}}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<button class="ui primary button">{{ctx.Locale.Tr "settings.update_avatar"}}</button>
|
||||
<button class="ui red button link-action" data-url="{{.Link}}/avatar/delete">{{ctx.Locale.Tr "settings.delete_current_avatar"}}</button>
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
<form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data">
|
||||
{{.CsrfTokenHtml}}
|
||||
<div class="inline field">
|
||||
<label for="avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
|
||||
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
|
||||
{{template "shared/avatar_upload_crop" dict "LabelText" (ctx.Locale.Tr "settings.choose_new_avatar")}}
|
||||
</div>
|
||||
<div class="field">
|
||||
<button class="ui primary button">{{ctx.Locale.Tr "settings.update_avatar"}}</button>
|
||||
|
|
8
templates/shared/avatar_upload_crop.tmpl
Normal file
8
templates/shared/avatar_upload_crop.tmpl
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{- /* we do not need to set for/id here, global aria init code will add them automatically */ -}}
|
||||
<label>{{.LabelText}}</label>
|
||||
<input class="avatar-file-with-cropper" name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
|
||||
{{- /* the cropper-panel must be next sibling of the input "avatar" */ -}}
|
||||
<div class="cropper-panel tw-hidden">
|
||||
<div class="tw-my-2">{{ctx.Locale.Tr "settings.cropper_prompt"}}</div>
|
||||
<div class="cropper-wrapper"><img class="cropper-source" src alt></div>
|
||||
</div>
|
|
@ -124,13 +124,7 @@
|
|||
</div>
|
||||
|
||||
<div class="inline field tw-pl-4">
|
||||
<label for="new-avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label>
|
||||
<input id="new-avatar" name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
|
||||
</div>
|
||||
|
||||
<div class="field tw-pl-4 cropper-panel tw-hidden">
|
||||
<div>{{ctx.Locale.Tr "settings.cropper_prompt"}}</div>
|
||||
<div class="cropper-wrapper"><img class="cropper-source" src alt></div>
|
||||
{{template "shared/avatar_upload_crop" dict "LabelText" (ctx.Locale.Tr "settings.choose_new_avatar")}}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue