Media Library

Aspect patterns

Common patterns for defining aspects

The Create an aspect guide covers how to define and deploy an aspect. This guide explores common patterns for defining aspects.

Prerequisites: sanity CLI v3.88.0 or newer.

Code-based features not supported

Aspect with a single string field

Aspect with a single boolean field

Aspect with multiple fields

Aspect with a global document reference

You can combine aspects with global document references. Use the globalDocumentReference type to target documents in another project and dataset. This example targets a photographer type in the example dataset of the project identified by <your-project-id>.

The resourceId value is the <your-project-id>.DATASET_NAME. As with normal references in Sanity Studio, you can use the preview property to select fields to display. In this case, it sets the preview title to the photographer.name field.

Learn more about global document references.

Public aspects

To query an aspect value from a dataset, mark the aspect definition as public.

Marking an aspect as public lets a dataset resolve the aspect value with media::aspect(MEDIA_REF, "NAME"), where MEDIA_REF is a reference to the media asset and NAME is the aspect name.

Was this page helpful?