mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	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:
		| @@ -6,7 +6,7 @@ type CropperOpts = { | ||||
|   fileInput: HTMLInputElement, | ||||
| } | ||||
|  | ||||
| export async function initCompCropper({container, fileInput, imageSource}: CropperOpts) { | ||||
| async function initCompCropper({container, fileInput, imageSource}: CropperOpts) { | ||||
|   const {default: Cropper} = await import(/* webpackChunkName: "cropperjs" */'cropperjs'); | ||||
|   let currentFileName = ''; | ||||
|   let currentFileLastModified = 0; | ||||
| @@ -38,3 +38,10 @@ export async function initCompCropper({container, fileInput, imageSource}: Cropp | ||||
|     } | ||||
|   }); | ||||
| } | ||||
|  | ||||
| export async function initAvatarUploaderWithCropper(fileInput: HTMLInputElement) { | ||||
|   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}); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user