Skip to content

Commit 129f5fc

Browse files
authored
Merge pull request #178 from episerver/bugfix/CMS-47074-Exception-on-AboutUs-component-if-there-is-no-data-for-image-property
Exception on AboutUs component if there is no data for image property
2 parents 6bcebbf + c8cdb2d commit 129f5fc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

samples/nextjs-template/src/components/AboutUs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { contentType, Infer } from '@optimizely/cms-sdk';
22
import { RichText, ElementProps } from '@optimizely/cms-sdk/react/richText';
3+
import { getPreviewUtils } from '@optimizely/cms-sdk/react/server';
34
import Image from 'next/image';
45

56
export const AboutUsContentType = contentType({
@@ -32,11 +33,12 @@ const customHeadingTwo = (props: ElementProps) => {
3233
};
3334

3435
export default function AboutUs({ opti }: AboutUsProps) {
36+
const { src } = getPreviewUtils(opti);
3537
return (
3638
<section className="about-us">
3739
{opti?.image?.url?.default && (
3840
<div className="about-us-image">
39-
<Image src={opti.image.url.default} alt="aboutus_image" />
41+
<Image src={src(opti.image.url.default)} alt="" fill={true}/>
4042
</div>
4143
)}
4244
<h2>{opti.heading}</h2>

0 commit comments

Comments
 (0)