Skip to content

Commit 182a1b7

Browse files
author
Gerardo Pacheco
authored
[Mobile] - Image block - Fix height and border regression (#34957)
* Mobile - Fix Image block height regression * Mobile - Image block - Check context exists
1 parent 0ccb4ed commit 182a1b7

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

packages/block-library/src/image/edit.native.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,14 @@ export class ImageEdit extends Component {
509509
image,
510510
clientId,
511511
imageDefaultSize,
512-
context: { imageCrop = false } = {},
512+
context,
513513
featuredImageId,
514514
wasBlockJustInserted,
515515
} = this.props;
516516
const { align, url, alt, id, sizeSlug, className } = attributes;
517+
const hasImageContext = context
518+
? Object.keys( context ).length > 0
519+
: false;
517520

518521
const imageSizes = Array.isArray( this.props.imageSizes )
519522
? this.props.imageSizes
@@ -627,9 +630,11 @@ export class ImageEdit extends Component {
627630

628631
const additionalImageProps = {
629632
height: '100%',
630-
resizeMode: imageCrop ? 'cover' : 'contain',
633+
resizeMode: context?.imageCrop ? 'cover' : 'contain',
631634
};
632635

636+
const imageContainerStyles = [ hasImageContext && styles.fixedHeight ];
637+
633638
const getImageComponent = ( openMediaOptions, getMediaOptions ) => (
634639
<Badge label={ __( 'Featured' ) } show={ isFeaturedImage }>
635640
<TouchableWithoutFeedback
@@ -662,7 +667,7 @@ export class ImageEdit extends Component {
662667
retryMessage,
663668
} ) => {
664669
return (
665-
<View style={ styles.isGallery }>
670+
<View style={ imageContainerStyles }>
666671
<Image
667672
align={
668673
align && alignToFlex[ align ]
@@ -686,7 +691,9 @@ export class ImageEdit extends Component {
686691
url={ url }
687692
shapeStyle={ styles[ className ] }
688693
width={ this.getWidth() }
689-
{ ...additionalImageProps }
694+
{ ...( hasImageContext
695+
? additionalImageProps
696+
: {} ) }
690697
/>
691698
</View>
692699
);

packages/block-library/src/image/styles.native.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
padding-bottom: $grid-unit;
3232
}
3333

34-
.isGallery {
34+
.fixedHeight {
3535
height: 150;
3636
overflow: visible;
3737
}

0 commit comments

Comments
 (0)