Simplify image uploads, optimization, and delivery with Sanity. This guide covers asset management in Sanity Studio, AI-powered enhancements, and serving optimized images via Sanity’s global CDN—with seamless Next.js integration.
Sanity Studio provides UI for asset uploads and editorial. The Content Lake provides APIs to do the same from your applications, and a global CDN to serve assets.
The customizable, React-based content editing dashboard configured with JavaScript. Run locally in a Vite development environment and deploy to your hosting—or ours.
AI Assist is a Sanity Studio plugin that allows authors to create context-aware instructions—along with automated tasks—to elevate the content creation experience.
You'll create a new free Sanity project using the Next.js template, publish new documents with Sanity Studio and explore how assets are uploaded, resized and embellished by AI Assist.
Visual Editing, the Presentation tool and Sanity Studio and are just a few parts of the Sanity Content Operating System. Get a fresh start on a new project or take a guided course for more.
At the top of the document, you will see a box saying "Used on 2 pages" which you can open to show the locations of the current document in the front end.
Click the first location and you'll see the front end open side-by-side with the document editor. Make a change to the document and press Publish. You'll see the document update again, without a reload!
The image rendered in the blog post is being cropped to a predetermined size and will be centered by default, but this may not be suitable for the image you uploaded.
Scroll to the Cover Image field in the document editor. You'll see the Crop icon in the top right hand corner. Click it, and you can now edit both the crop and focal area of the image.
Narrow the circle in the image to the part of the image you always want in view, and the crop area to the outer limits of what you would prefer to see.
You should see the front-end preview update as you make changes to the crop and focal areas. The image will still be the same pixel dimensions as before, but the region that is cropped is now effected by your choices in the Studio.
This feature allows editors to create curated images, without uploading multiple versions that are cropped with other tools, while your front-end renders consistent images on any page.
This template already has the AI Assist Studio plugin installed with some configuration settings. For this image field, the option to automatically generate alt text is available—however AI Assist is opt-in.
If you click the Assist icon above the Alternative text field, you should see an instruction Generate image description. Click this, and then click Enable AI Assist.
Click Generate image description again and you will see the assistant go to work, and briefly after write the alternative text directly to the field.
With AI Assist now activated—this is now automatic for future images! Try it by clearing the image field, uploading (or selecting) another image and the assistant will update the field value.
Content types in Sanity Studio are made available by configuration files that are all registered to your sanity.config.ts file (explained below). This particular file registers the document type post and includes many fields, including this one named coverImage.
There are many field types available and every type has unique options. For this image field type the hotspot option is enabled.
The configuration of aiAssist is also found here, which enables the assistant to write an automatically generated description to the nominated field path.
All of your Sanity Studio's configuration can be found in sanity.config.ts, scroll down to the plugins section and you will see the unsplashImageAsset and assist plugins.
This component takes the value of the coverImage field—when queried by Sanity Client—and renders it into Next.js Image component.
This works because of the urlForImage function which takes the response from the Content Lake, and generates a unique URL to return the image at a specific size (1280x720) in the most efficient format possible for this browser.
To see what the original source data looks like, open the Vision tool in Sanity Studio and perform this query:
*[_type == "post"].coverImage
In the response you should see something like this, which contains the crop and hotspot dimensions, the alt text generated by AI Assist, and a "reference" to the image by its ID.
This asset reference could be expanded to reveal even more metadata about the original image document—but its ID alone is enough to generate this URL thanks to the Sanity Image Builder library.
Commit this repository to your Git provider and deploy to Vercel to share these live previews with content creators
Add or edit Sanity Studio schema types. The template comes with a few already created, try adding a new field to post.ts in the /studio directory and see how the Studio updates imediately.
Explore GROQ, queries.ts in the /nextjs-app directory contains all the queries that the Next.js app currently makes. You can test queries in the Studio using the Vision tool.
Take the Day One with Sanity Studio Course to get a from-the-ground-up understanding of how to create new Sanity projects.
How to add custom asset sources for Sanity Studio.
Course • Sanity Learn
Day one content operations
Get a top-level understanding of the entire Sanity Content Operating System while building out a multi-application monorepo. With callouts to take other course material to go deeper.