@@ -47,8 +47,30 @@ export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, req
4747}
4848
4949export function getRequestedImageSize ( src : { width : number ; height : number } , options : ImageAssetOptions ) : { width : number ; height : number } {
50- let reqWidth = options . width || Math . min ( src . width , Screen . mainScreen . widthPixels ) ;
51- let reqHeight = options . height || Math . min ( src . height , Screen . mainScreen . heightPixels ) ;
50+ const optionsCopy = { ...( this . options || { } ) } ;
51+
52+ if ( typeof optionsCopy . width === 'string' ) {
53+ const parsedWidth = parseInt ( optionsCopy . width , 10 ) ;
54+ if ( ! isNaN ( parsedWidth ) ) {
55+ optionsCopy . width = parsedWidth ;
56+ } else {
57+ console . warn ( 'Invalid width value provided: ' , optionsCopy . width ) ;
58+ delete optionsCopy . width ;
59+ }
60+ }
61+
62+ if ( typeof optionsCopy . height === 'string' ) {
63+ const parsedHeight = parseInt ( optionsCopy . height , 10 ) ;
64+ if ( ! isNaN ( parsedHeight ) ) {
65+ optionsCopy . height = parsedHeight ;
66+ } else {
67+ console . warn ( 'Invalid height value provided: ' , options . height ) ;
68+ delete optionsCopy . height ;
69+ }
70+ }
71+
72+ let reqWidth = optionsCopy . width || Math . min ( src . width , Screen . mainScreen . widthPixels ) ;
73+ let reqHeight = optionsCopy . height || Math . min ( src . height , Screen . mainScreen . heightPixels ) ;
5274
5375 if ( options && options . keepAspectRatio ) {
5476 const safeAspectSize = getAspectSafeDimensions ( src . width , src . height , reqWidth , reqHeight ) ;
0 commit comments