Fix: Profile picture cropping supported #10703 (#11221)

### What problem does this PR solve?

Fix: Profile picture cropping supported

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
chanx
2025-11-13 09:50:10 +08:00
committed by GitHub
parent 8ef2f79d0a
commit 83d84e90ed
4 changed files with 292 additions and 7 deletions

View File

@ -2,7 +2,10 @@ import { FileMimeType } from '@/constants/common';
import fileManagerService from '@/services/file-manager-service';
import { UploadFile } from 'antd';
export const transformFile2Base64 = (val: any): Promise<any> => {
export const transformFile2Base64 = (
val: any,
imgSize?: number,
): Promise<any> => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(val);
@ -19,7 +22,7 @@ export const transformFile2Base64 = (val: any): Promise<any> => {
// Calculate compressed dimensions, set max width/height to 800px
let width = img.width;
let height = img.height;
const maxSize = 100;
const maxSize = imgSize ?? 100;
if (width > height && width > maxSize) {
height = (height * maxSize) / width;