@@ -18,7 +18,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
1818import useStyleUtils from '@hooks/useStyleUtils' ;
1919import useTheme from '@hooks/useTheme' ;
2020import useThemeStyles from '@hooks/useThemeStyles' ;
21- import { cleanFileName , showCameraPermissionsAlert , verifyFileFormat } from '@libs/fileDownload/FileUtils' ;
21+ import { cleanFileName , resizeImageIfNeeded , showCameraPermissionsAlert , verifyFileFormat } from '@libs/fileDownload/FileUtils' ;
2222import type { FileObject , ImagePickerResponse as FileResponse } from '@pages/media/AttachmentModalScreen/types' ;
2323import CONST from '@src/CONST' ;
2424import type { TranslationPaths } from '@src/languages/types' ;
@@ -341,32 +341,38 @@ function AttachmentPicker({
341341 } ;
342342
343343 if ( ! shouldValidateImage && fileDataName && Str . isImage ( fileDataName ) ) {
344- return ImageSize . getSize ( fileDataUri )
345- . then ( ( { width, height} ) => {
346- fileDataObject . width = width ;
347- fileDataObject . height = height ;
348- return fileDataObject ;
349- } )
350- . then ( ( file ) => getDataForUpload ( file ) )
344+ return getDataForUpload ( fileDataObject )
345+ . then ( ( file ) => resizeImageIfNeeded ( file ) )
346+ . then ( ( resizedFile ) =>
347+ ImageSize . getSize ( resizedFile . uri ?? '' ) . then ( ( { width, height} ) => ( {
348+ ...resizedFile ,
349+ width,
350+ height,
351+ } ) ) ,
352+ )
351353 . catch ( ( ) => {
352354 showImageCorruptionAlert ( ) ;
353355 return null ;
354356 } ) ;
355357 }
356358
357359 if ( fileDataName && Str . isImage ( fileDataName ) ) {
358- return ImageSize . getSize ( fileDataUri )
359- . then ( ( { width, height} ) => {
360- fileDataObject . width = width ;
361- fileDataObject . height = height ;
362-
363- if ( fileDataObject . width <= 0 || fileDataObject . height <= 0 ) {
364- showImageCorruptionAlert ( ) ;
365- return null ;
366- }
367-
368- return getDataForUpload ( fileDataObject ) ;
369- } )
360+ return getDataForUpload ( fileDataObject )
361+ . then ( ( file ) => resizeImageIfNeeded ( file ) )
362+ . then ( ( resizedFile ) =>
363+ ImageSize . getSize ( resizedFile . uri ?? '' ) . then ( ( { width, height} ) => {
364+ if ( width <= 0 || height <= 0 ) {
365+ showImageCorruptionAlert ( ) ;
366+ return null ;
367+ }
368+
369+ return {
370+ ...resizedFile ,
371+ width,
372+ height,
373+ } ;
374+ } ) ,
375+ )
370376 . catch ( ( ) => {
371377 showImageCorruptionAlert ( ) ;
372378 return null ;
0 commit comments