diff --git a/examples/next/faustwp-getting-started/components/FeaturedImage/FeaturedImage.js b/examples/next/faustwp-getting-started/components/FeaturedImage/FeaturedImage.js index e05a20607..40a4a78cb 100644 --- a/examples/next/faustwp-getting-started/components/FeaturedImage/FeaturedImage.js +++ b/examples/next/faustwp-getting-started/components/FeaturedImage/FeaturedImage.js @@ -10,25 +10,33 @@ export default function FeaturedImage({ ...props }) { const src = image?.sourceUrl; - const { altText } = image || ''; - width = width ? width : image?.mediaDetails?.width; - height = height ? height : image?.mediaDetails?.height; + if (!src) return null; + + const { altText = '', mediaDetails = {} } = image ?? {}; + layout = layout ?? 'fill'; - return src && width && height ? ( + const dimensions = { + width: layout === 'fill' ? undefined : width ?? mediaDetails?.width, + height: layout === 'fill' ? undefined : height ?? mediaDetails?.height + }; + + if (layout !== 'fill' && (!dimensions.width || !dimensions.height)) return null; + + return (
{altText}
- ) : null; + ); } FeaturedImage.fragments = {