Issue with returning null value for blurhash in image schema resolved with help from Geoff.
3 replies
Last updated: Jun 16, 2023
R
Hey everyone! My image
In my Vision tool I keep getting a
My
blurhashalways returns a
nullvalue and I am not sure why.. Here is my groq query:
*[_type == "homePage"] | order(_updatedAt desc) [0] { sections[] { ..., _type == "contentImage" => { ..., image { ..., "height": asset->metadata.dimensions.height, "width": asset->metadata.dimensions.width, "dimensions": asset->metadata.dimensions, "blurhash": asset->metadata.blurHash, "lqip": asset->metadata.lqip } } } }
nullvalue, but all other values work..
My
pictureschema is like this:
export default { title: 'Image', name: 'picture', type: 'image', icon: ImageSquare, options: { hotspot: true, metadata: ['lqip', 'blurhash'] }, fields: [ { title: 'Alternative Text', name: 'alt', type: 'string', description: 'A short description of the image. Important for SEO and accessiblity.', validation: (Rule) => Rule.required() }, { title: 'Display Size (Aspect Ratio)', name: 'customRatio', type: 'string', description: 'Select how the image is displayed. This affects the aspect ratio of the image within its container.', options: { list: aspectRatios }, initialValue: 'aspect-0' } ], preview: { select: { alt: 'alt', filename: 'asset.originalFilename', dimensions: 'asset.metadata.dimensions', image: 'asset' }, prepare({ alt, dimensions, filename, image }) { return { title: alt ?? filename, subtitle: dimensions ? `${dimensions.width}px × ${dimensions.height}px` : '…', media: image ?? ImageSquare } } } }
Jun 16, 2023, 6:17 PM
Hi (Removed Name). Is
contentImagein your
homePageschema of the type
picture? If it is, was
blurhashspecified in your
metadataarray at the time the image was uploaded?
Jun 16, 2023, 6:30 PM
R
Hi
user A
No lol.. sorry its a bit confusing, the pictureis the name of the schema, but it is a type of
image. Hmm no it wasn't specified in my image at the time of upload.. Let me give that a try
Jun 16, 2023, 6:32 PM
R
Oh wow its working now haha.. Seems I had to upload the images after I declared my
metadata: ['lqip', 'blurhash']. Thanks for the help (Removed Name) you're the man
Jun 16, 2023, 6:38 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.