Image metadata
This article takes a closer look at the types of metadata available for images and the values they might return.
The metadata option for image fields controls which types of metadata Sanity extracts or generates from uploaded images and saves alongside the asset.
Image assets in your Content Lake may include a range of helpful metadata.
- Always included: Essential facts about your image, including height, width, aspect ratio, and information about transparency.
- Included by default: Useful information generated from the image on upload: minified placeholders and palette values.
- Excluded by default: Potentially private information about the place and circumstances under which the image was created, held in the
exif,image, andlocationvalues.
An example of an image field with every metadata option specified looks as follows:
{
name: 'metaImage',
title: 'Image with metadata',
type: 'image',
options: {
metadata: [
'blurhash', // Default: included
'thumbhash', // Default: included
'lqip', // Default: included
'palette', // Default: included
'image', // Default: not included
'exif', // Default: not included
'location', // Default: not included
],
},
},There are three additional metadata options that are always included and cannot be disabled: dimensions, hasAlpha, and isOpaque. Specifying an invalid option in the metadata array (including any of those three terms) will throw an error.
The metadata fields fall into one of three "default behaviors": always included, included by default, and excluded by default. We'll look at each default setting and the metadata fields that adhere to it.
Gotcha
Some metadata is computed synchronously on upload, while other values are added asynchronously. If your query for image metadata returns unexpectedly empty, wait a moment and try again.
Gotcha
Metadata is applied to an image asset when the image is uploaded and based on the schema settings at that time. If a metadata array is set to include exif or location data, changing the schema later will not remove those details. If removing those details is desired, you can do so with a script or using the Media browser plugin, among other options. Likewise, adding options to the metadata array will not add those details to images previously uploaded.