Watch a live product demo 👀 See how Sanity powers richer commerce experiences

Is there a way to override the hotspot and crop for previews?

3 replies
Last updated: Dec 4, 2020
I’m working on my document previews in Sanity Studio. When I add images, the Sanity docs say “The easiest way to show an image in the preview is to assign a field containing an image to the
property [which I’ve done]. The different views take care of a proper rendering of the image, including any
Is there a way to somehow override the hotspot and crop for the previews? I’d like the preview image to be zoomed in on their faces.
Dec 3, 2020, 9:56 PM
You can override it like this:
import React from 'react'

export default {
  name: 'post',
  type: 'document',
  title: 'Post',
  fields: [
      name: 'title',
      type: 'string',
      name: 'image',
      type: 'image',
      options: {
        hotspot: true
  preview: {
    select: {
      title: 'title',
      media: 'image.asset.url'
    prepare({title, media}) {
      return {
        media: () => <img src={media} />,

Dec 4, 2020, 12:22 PM
Thanks for the reply,
user Y
. I apologize as I wasn’t very clear before. What I’m hoping to do is apply specific crop settings just to the Studio preview image (ignoring whatever is set in the Studio). I can usually assume the face is at around 50% on the x-axis and about 20% down on the y-axis. I’ve tried something like the following but can’t find a way to zoom in on the image based on a focal point of (0.5, 0.2). Since width and height are in pixels, I can’t use those, since the images are all uploaded with different dimensions.

preview: {
    select: {
      image: 'image.asset.url',
    prepare({..., image}) {
      return {
        media: () => <img src={urlFor(image).width(100).height(100).focalPoint(0.5, 0.2).crop('focalpoint').fit('max')} />,
Dec 4, 2020, 11:20 PM
I think that since it’s going to be so customized for each image, I’m better off adding another field to use as the preview image. Thanks for your help,
user Y
Dec 4, 2020, 11:28 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing