How to upload and get URLs for multiple images in Sanity, and add captions to individual images.
Great questions! Let me help you with both issues.
Problem 1: Getting Image URLs from an Array
Your GROQ query is almost correct, but you need to account for the array structure. Since ProjectImages is an array, you need to query each item in the array:
ProjectImages[]{
asset->{
_id,
url
}
}The key difference is adding [] after ProjectImages - this tells GROQ to iterate over the array and get the asset reference for each image.
This will return an array of objects like:
[
{
"asset": {
"_id": "image-abc123...",
"url": "https://cdn.sanity.io/images/..."
}
},
{
"asset": {
"_id": "image-def456...",
"url": "https://cdn.sanity.io/images/..."
}
}
]If you want just the URLs in a flatter structure, you can use:
"projectImages": ProjectImages[].asset->urlThis will give you a simple array of URL strings.
Problem 2: Multi-Select Image Upload
Unfortunately, Sanity Studio doesn't currently support native multi-select for image uploads in array fields. You have to upload images one at a time by default.
However, you can drag and drop multiple images at once! Instead of clicking the upload button repeatedly:
- Select multiple image files from your file explorer
- Drag them all together onto the image array field in Studio
- Sanity will process and add them all sequentially
This is much faster than clicking upload for each individual image. The drag-and-drop functionality works in modern versions of Sanity Studio (v3 and later) and is the recommended approach for bulk image uploads.
For more advanced multi-select functionality, you'd need to create a custom input component using Sanity's custom input widgets, but the drag-and-drop approach should solve your workflow issue without any custom code.
Hope this helps! Let me know if you run into any issues with these solutions.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.