Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Feb 5, 2025
1 parent 546f133 commit ac80d4e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion templates/shared/avatar_upload_crop.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- /* we do not need to set for/id here, global aria init code will add them automatically */ -}}
<label>{{.LabelText}}</label>
<input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp">
{{- /* the cropper-panel must be next sibling of the input "js-avatar-with-cropper" */ -}}
{{- /* the cropper-panel must be next sibling of the input "avatar" */ -}}
<div class="cropper-panel tw-hidden">
<div>{{ctx.Locale.Tr "settings.cropper_prompt"}}</div>
<div class="cropper-wrapper"><img class="cropper-source" src alt></div>
Expand Down
4 changes: 2 additions & 2 deletions web_src/js/features/comp/Cropper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ async function initCompCropper({container, fileInput, imageSource}: CropperOpts)

export async function initAvatarUploaderWithCropper(fileInput?: HTMLInputElement) {
if (!fileInput) return;
const panel = queryElemSiblings(fileInput, '.cropper-panel')[0] as HTMLElement;
if (!panel) return;
const panel = fileInput.nextElementSibling as HTMLElement;
if (!panel?.matches('.cropper-panel')) throw new Error('Missing cropper panel for avatar uploader');
const imageSource = panel.querySelector<HTMLImageElement>('.cropper-source');
await initCompCropper({container: panel, fileInput, imageSource});
}

0 comments on commit ac80d4e

Please sign in to comment.