docs
ImageObject Schema
Add ImageObject structured data to your Sanity documents to provide image metadata and improve Google Images indexing.
About ImageObject Schema
ImageObject schema provides metadata about images, improving Google Images indexing. By adding ImageObject markup, you give search engines explicit information about image dimensions, captions, and licensing, helping your images appear more prominently in image search results and knowledge panels.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| url | string | Required | The URL of the image file. |
| width | number | Optional | The width of the image in pixels. |
| height | number | Optional | The height of the image in pixels. |
| caption | string | Optional | A text caption describing the image content. |
Plugin Registration
sanity.config.ts
import { defineConfig } from "sanity";
import { seoFields } from "sanity-plugin-seofields";
import { schemaOrgImageObjectPlugin } from "sanity-plugin-seofields/schema";
export default defineConfig({
// ...your sanity config
plugins: [
seoFields(),
schemaOrgImageObjectPlugin(),
],
});Schema Usage
Add theschemaOrgImageObject field to any document schema:
schemas/page.ts
import { defineField, defineType } from 'sanity'
export default defineType({
name: 'page',
title: 'Page',
type: 'document',
fields: [
// ... your other fields
defineField({
name: 'schemaOrgImageObject',
title: 'Image Object',
type: 'schemaOrgImageObject',
}),
],
})GROQ Query
GROQ
*[_type == "yourDocumentType"][0]{
...,
schemaOrgImageObject
}Next.js Component
app/page.tsx
import { ImageObjectSchema } from "sanity-plugin-seofields/schema-org/next";
export default function Page({ data }) {
return (
<>
<ImageObjectSchema data={data.schemaOrgImageObject} />
{/* Your page content */}
</>
);
}JSON-LD Output
JSON-LD
{
"@context": "https://schema.org",
"@type": "ImageObject",
"url": "https://example.com/photo.jpg",
"width": 1200,
"height": 630,
"caption": "Product hero image"
}Was this page helpful?