Media Library

Aspect patterns

Common patterns for defining aspects

In the Create an aspect guide you learned 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

Single string field

Single boolean field

Multiple fields

Global references

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 3do82whm project.

The resourceId value is the projectId.datasetName. As with normal references in 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

If you want to query an aspect value from a dataset the easiest way is to mark the aspect definition as public.

This allows a dataset to resolve the aspect value by using media::aspect(MEDIA_REF, "NAME")

Was this page helpful?