import { cn } from '@/lib/utils'; import { getImageDimensions } from '@sanity/asset-utils'; import { urlForImage } from 'lib/sanity/sanity.image'; import Image from 'next/image'; interface SanityImageProps { image: object | any; alt?: string; priority?: boolean; width?: number; height?: number; size?: string; className?: string; fill?: boolean; } // const placeholderImg = '/product-img-placeholder.svg'; export default function SanityImage({ image, alt = image?.alt ?? 'An image without an alt, whoops', size = '100vw', fill = false, priority = false, width, height, className }: SanityImageProps) { const imageUrl = image && urlForImage(image).url(); return (
{fill && imageUrl && ( {alt} )} {!fill && imageUrl && ( {alt} )}
); }