Skip to content

Commit 193e71b

Browse files
committed
add stega fix for cover image
1 parent 8f86bbf commit 193e71b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎components/cover-image.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { CloudinaryAsset } from "@/sanity/types";
22
import CloudinaryImage from "@/components/cloudinary-image";
33
import { getCldImageUrl } from "next-cloudinary";
4+
import { stegaClean } from "@sanity/client/stega";
45

56
interface CoverImageProps {
67
image: CloudinaryAsset | null | undefined;
@@ -21,6 +22,9 @@ export default async function CoverImage(props: CoverImageProps) {
2122
quality,
2223
} = props;
2324

25+
const source = stegaClean(originalImage);
26+
27+
2428
const getImageUrl = async (src: string) => {
2529
const imageUrl = getCldImageUrl({
2630
src,
@@ -34,7 +38,7 @@ export default async function CoverImage(props: CoverImageProps) {
3438
};
3539

3640
let image: JSX.Element | undefined;
37-
if (originalImage?.public_id) {
41+
if (source?.public_id) {
3842
image = (
3943
<CloudinaryImage
4044
className={className || "w-full h-auto aspect-video rounded-md"}
@@ -43,10 +47,10 @@ export default async function CoverImage(props: CoverImageProps) {
4347
priority={priority}
4448
quality={quality || "auto"}
4549
sizes="(max-width: 768px) 100vw,(max-width: 1200px) 50vw, 33vw"
46-
alt={originalImage?.context?.custom?.alt || ""}
47-
src={originalImage?.public_id}
50+
alt={source?.context?.custom?.alt || ""}
51+
src={source?.public_id}
4852
placeholder="blur"
49-
blurDataURL={await getImageUrl(originalImage.public_id)}
53+
blurDataURL={await getImageUrl(source.public_id)}
5054
/>
5155
);
5256
} else {

0 commit comments

Comments
 (0)