import { cn } from '@/lib/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 = '', width = 3500, height = 2000, size = '100vw', fill = false, priority = false, className }: SanityImageProps) { const imageUrl = image && urlForImage(image)?.height(height).width(width).fit('crop').url(); return (
{fill && imageUrl && ( {alt} )} {imageUrl && ( {alt )}
); } // export default function SanityImage(props: SanityImageProps) { // const { // image: source, // priority = false, // alt = '', // height = 1080, // width = 1080, // sizes = '100vw', // className, // fill = false // } = props; // const rootClassName = cn('w-full h-auto', className); // const image = source?.asset ? ( // <> // {fill ? ( // {alt} // ) : ( // {alt} // )} // // ) : ( // <> // {alt} // // ); // return image; // }