
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou've actually discovered one of the most powerful and flexible patterns for managing images in Sanity! Your "photo as a document" approach is not only valid but often the recommended best practice for structured media management with rich metadata. Let me explain why this works so well and when you might consider alternatives.
Your approach of creating a photo document type with custom metadata fields and an image field is exactly what many experienced Sanity developers do. Here's why it's powerful:
1. Metadata Travels With Content By storing alt text, titles, and other metadata at the document level, you ensure this information is always accessible and can be updated in one place. When you reference this photo elsewhere, you're referencing the entire package of image + metadata.
2. Full GROQ Query Power You can search, filter, and query your photos using all of Sanity's GROQ capabilities. Want to find all photos by a specific artist from the Renaissance period? Easy with your schema.
3. Version Control Built-In When you upload a new image to an existing photo document, you're essentially versioning that asset while keeping all the metadata and references intact.
4. Reusability Using references (as you did with your carousel) means updating the photo in one place updates it everywhere it's used.
The native image type does support custom fields directly on the image field itself:
{
name: 'image',
type: 'image',
fields: [
{name: 'alt', type: 'string', title: 'Alt text'},
{name: 'caption', type: 'string', title: 'Caption'}
]
}However, this approach has limitations:
Sanity does offer an Enterprise Media Library with advanced features like:
This is overkill for most projects and requires an Enterprise plan. Your document pattern gives you 90% of these benefits without the cost.
Third-party plugins like sanity-plugin-media are useful when:
However, these plugins typically store metadata on the asset document itself, which can be harder to query from your content documents compared to your reference pattern.
Your pattern is solid, but here are some refinements:
1. Add Asset Metadata Extraction You can still leverage Sanity's built-in image metadata like EXIF data, dimensions, and color palette:
{
name: "image",
type: "image",
options: {
hotspot: true,
metadata: ['exif', 'palette', 'location']
}
}2. Consider Validation Make alt text required for accessibility:
{
type: 'string',
name: 'alt',
title: 'Alt Text',
validation: Rule => Rule.required()
}3. Add Preview Configuration Make your photo documents easier to browse:
preview: {
select: {
title: 'title',
media: 'image'
}
}Your approach is not missing anything critical. You've independently discovered a pattern that scales well for structured content. The document-as-media-object pattern is particularly well-suited for:
Stick with your pattern unless you need organization-wide asset management across multiple projects (Enterprise Media Library) or just want a prettier upload UI (community plugins). You're building on solid Sanity fundamentals, and your 10-minute solution is better than many over-engineered alternatives.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store