-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathblock-image.tsx
More file actions
36 lines (31 loc) · 990 Bytes
/
block-image.tsx
File metadata and controls
36 lines (31 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import Image from "next/image";
import { urlForImage } from "@/sanity/lib/image";
interface BlockImageProps {
image: any;
}
export default function BlockImage(props: BlockImageProps) {
const { image } = props;
const imageUrl = image?.asset?._ref
? urlForImage(image)?.width(1920).height(1080).url()
: null;
if (!imageUrl) {
return (
<div className="shadow-md transition-shadow duration-200 group-hover:shadow-lg sm:mx-0">
<div className="bg-slate-50" style={{ paddingTop: "50%" }} />
</div>
);
}
return (
<div className="shadow-md transition-shadow duration-200 group-hover:shadow-lg sm:mx-0">
<Image
className="w-full h-auto"
width={1920}
height={1080}
sizes="100vw"
alt={image?.alt || ""}
src={imageUrl}
unoptimized
/>
</div>
);
}