@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
29 lines (28 loc) • 1.14 kB
TypeScript
import type { ImgixURLParams } from "imgix-url-builder";
import type { ImageFieldImage } from "../types/value/image";
/**
* The return type of `asImageSrc()`.
*/
type AsImageSrcReturnType<Field extends ImageFieldImage | null | undefined> = Field extends ImageFieldImage<"filled"> ? string : null;
/**
* Returns the URL of an image field with optional image transformations (via
* Imgix URL parameters).
*
* @example
*
* ```ts
* const src = asImageSrc(document.data.imageField, { sat: -100 })
* // => https://images.prismic.io/repo/image.png?sat=-100
* ```
*
* @param field - Image field (or one of its responsive views) from which to get
* an image URL.
* @param config - An object of Imgix URL API parameters to transform the image.
*
* @returns The image field's image URL with transformations applied (if given).
* If the image field is empty, `null` is returned.
*
* @see Imgix URL parameters reference: https://docs.imgix.com/apis/rendering
*/
export declare const asImageSrc: <Field extends ImageFieldImage | null | undefined>(field: Field, config?: ImgixURLParams) => AsImageSrcReturnType<Field>;
export {};