Sanity Library Reference Docs
    Preparing search index...

    Function Image

    • Alpha

      Renders an image from the Sanity Image CDN with next/image.

      Unlike next/image, width and height are optional: when omitted they are inferred, in order of precedence, from the URL's w/h params (e.g. set by an @sanity/image-url builder), its rect crop param, or the original dimensions Sanity encodes in every asset filename. Providing only one dimension derives the other from the image's aspect ratio, like next/image does for static imports.

      Image objects from GROQ queries are supported directly: the crop set in the Studio is applied, the crop region is positioned around the hotspot when the requested dimensions change the aspect ratio, and placeholder="blur" uses asset->metadata.lqip when no blurDataURL is provided.

      With fill, the browser crops the image to its parent. When src is an image object with a hotspot, object-position defaults to that hotspot as percentages of the cropped image, clamped so the image still covers the box. A flip query param is mirrored, then an or rotation is applied clockwise. style.objectPosition and the objectPosition prop override it.

      Parameters

      Returns Element