File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -131,17 +131,23 @@ export async function checkImageDimensions(
131131 if ( ! width || ! height ) {
132132 errorMessages . push ( `Image metadata could not be read for ${ filePath } ` ) ;
133133 } else {
134- if ( isWidthExact && width !== maxWidth ) {
135- errorMessages . push ( `Image width is ${ width } px, but expected ${ maxWidth } px` ) ;
136- }
137-
138- if ( isHeightExact && height !== maxHeight ) {
139- errorMessages . push ( `Image height is ${ height } px, but expected ${ maxHeight } px` ) ;
134+ if ( isWidthExact ) {
135+ if ( width !== maxWidth ) {
136+ errorMessages . push ( `Image width is ${ width } px, but expected exactly ${ maxWidth } px` ) ;
137+ }
138+ } else {
139+ if ( width > maxWidth ) {
140+ errorMessages . push ( `Image width is ${ width } px, which exceeds the maximum allowed ${ maxWidth } px` ) ;
141+ }
140142 }
141143
142- if ( ! isWidthExact && ! isHeightExact ) {
143- if ( width > maxWidth || height > maxHeight ) {
144- errorMessages . push ( `Image dimensions ${ width } x${ height } px exceed maximum ${ maxWidth } x${ maxHeight } px` ) ;
144+ if ( isHeightExact ) {
145+ if ( height !== maxHeight ) {
146+ errorMessages . push ( `Image height is ${ height } px, but expected exactly ${ maxHeight } px` ) ;
147+ }
148+ } else {
149+ if ( height > maxHeight ) {
150+ errorMessages . push ( `Image height is ${ height } px, which exceeds the maximum allowed ${ maxHeight } px` ) ;
145151 }
146152 }
147153 }
You can’t perform that action at this time.
0 commit comments