@@ -10,7 +10,7 @@ import {
10
10
} from '@sitecore-jss/sitecore-jss-nextjs' ;
11
11
12
12
interface Fields {
13
- Image : ImageField ;
13
+ Image : ImageField & { metadata ?: { [ key : string ] : unknown } } ;
14
14
ImageCaption : Field < string > ;
15
15
TargetUrl : LinkField ;
16
16
}
@@ -31,19 +31,22 @@ const ImageDefault = (props: ImageProps): JSX.Element => (
31
31
export const Banner = ( props : ImageProps ) : JSX . Element => {
32
32
const { sitecoreContext } = useSitecoreContext ( ) ;
33
33
const isPageEditing = sitecoreContext . pageEditing ;
34
+ const isMetadataMode = sitecoreContext ?. editMode === 'metadata' ;
34
35
const classHeroBannerEmpty =
35
36
isPageEditing && props . fields ?. Image ?. value ?. class === 'scEmptyImage'
36
37
? 'hero-banner-empty'
37
38
: '' ;
38
39
const backgroundStyle = ( props ?. fields ?. Image ?. value ?. src && {
39
40
backgroundImage : `url('${ props . fields . Image . value . src } ')` ,
40
41
} ) as CSSProperties ;
41
- const modifyImageProps = {
42
- ...props . fields . Image ,
43
- editable : props ?. fields ?. Image ?. editable
44
- ?. replace ( `width="${ props ?. fields ?. Image ?. value ?. width } "` , 'width="100%"' )
45
- . replace ( `height="${ props ?. fields ?. Image ?. value ?. height } "` , 'height="100%"' ) ,
46
- } ;
42
+ const modifyImageProps = ! isMetadataMode
43
+ ? {
44
+ ...props . fields . Image ,
45
+ editable : props ?. fields ?. Image ?. editable
46
+ ?. replace ( `width="${ props ?. fields ?. Image ?. value ?. width } "` , 'width="100%"' )
47
+ . replace ( `height="${ props ?. fields ?. Image ?. value ?. height } "` , 'height="100%"' ) ,
48
+ }
49
+ : { ...props . fields . Image } ;
47
50
const id = props . params . RenderingIdentifier ;
48
51
49
52
return (
0 commit comments