import { FC } from 'react'; import { imageFrom } from '@uniformdev/assets'; import BaseImage from '@/components/ui/Image'; import MediaPlaceholder from '@/components/ui/MediaPlaceholder'; import { ReplaceFieldsWithAssets } from '@/types/cskTypes'; import { withFlattenParameters } from '@/utils/withFlattenParameters'; import { ImageParameters, ImageProps } from '.'; const Image: FC> = async ({ image, objectFit, width, height, overlayColor, overlayOpacity, border, priority, fill, unoptimized, context, component, }) => { const [resolvedImage] = image || []; if (!resolvedImage?.url) { const isEditorPreviewMode = context.isContextualEditing; const isPlaceholder = component?._id?.includes('placeholder_'); if (!isEditorPreviewMode || isPlaceholder) { return null; } return (
); } const { focalPoint, title = '' } = resolvedImage; const imageWidth = width || resolvedImage.width; const imageHeight = height || resolvedImage.height; if (!fill && (!imageWidth || !imageHeight)) { console.warn( 'No dimensions provided for the Next.js Image component. Falling back to a standard tag for rendering.' ); // eslint-disable-next-line @next/next/no-img-element return {title}; } const imageUrl = imageFrom(resolvedImage.url) .transform({ width: width, height: height, fit: objectFit, focal: focalPoint, }) .url(); const variantBasedProps = fill ? { fill: true } : { width: imageWidth, height: imageHeight, }; return ( ); }; export default withFlattenParameters(Image);