Capital/sanity/lib/image.ts

14 lines
366 B
TypeScript
Raw Normal View History

2024-02-24 13:56:35 +00:00
import createImageUrlBuilder from "@sanity/image-url";
import type { Image } from "sanity";
import { dataset, projectId } from "../env";
const imageBuilder = createImageUrlBuilder({
projectId: projectId || "",
dataset: dataset || "",
});
export const urlForImage = (source: Image) => {
return imageBuilder?.image(source).auto("format").fit("max").url();
};