Issue with alt_text in Sanity Studio resolved by uploading an image

13 replies
Last updated: Mar 25, 2021
Why doesn't the alt_text show up in studio?
AI Update

Based on the documentation, there are a few common reasons why alt_text might not be showing up in Studio:

1. The field isn't defined in your schema

The most common issue is that alt_text (or alt) needs to be explicitly added as a custom field in your image type definition. Images in Sanity don't automatically include an alt text field - you need to add it yourself:

{
  name: 'image',
  title: 'Image',
  type: 'image',
  options: {
    hotspot: true
  },
  fields: [
    {
      name: 'alt',
      title: 'Alt Text',
      type: 'string',
      description: 'Important for SEO and accessibility'
    }
  ]
}

2. Field name mismatch

Make sure you're using the correct field name. If you defined it as alt in your schema but are looking for alt_text, it won't appear. Check your schema definition to confirm the exact field name you used.

3. The field is hidden or has conditional logic

If you've added any hidden properties or conditional logic to your field definition, it might not be visible under certain conditions. Check if there are any hidden or readOnly configurations on the field.

4. Schema changes not reflected

After adding the field to your schema, make sure you've restarted your Studio dev server. Schema changes require a restart to take effect.

Once you've added the field properly to your schema, it will appear as an editable field when you click on the image in Studio, and you can query it alongside your image data using GROQ.

You can find more details about adding custom fields to images in the Image Type documentation and this guide on displaying images.

how does your groq query look like?
Haven't got that far yet, I cant see it in the Sanity Studio:
but when i place the alt_text object outside of the image objects fields it works. Like this:
        {
            title: "Company Image",
            description: "Logotype for company",
            name: "image",
            type: "image",
            options: {
                accept: "image/png",
            },
            fields: [
            ],
        },
        {
            name: "alt_text",
            type: "localeString",
            title: "Alternative Image text",
            description: "Important for SEO and accessibility",
        },
    ],
Then it looks like it should except that its not nested:
Not really a big problem but was curious to why this is πŸ™‚
Hi User. What does the schema for your
localeString
look like?
Hi! it looks like this:
import { supportedLanguages } from "./supportedLanguages";

export default {
  title: "LocaleString",
  name: "localeString",
  type: "object",
  fieldsets: [
    {
      title: "Translations",
      name: "translations",
      options: { collapsible: false },
    },
  ],
  fields: supportedLanguages.map((lang) => ({
    title: lang.title,
    name: lang.id,
    type: "string",
    fieldset: lang.isDefault ? null : "translations",
  })),
};
And supportedLanguages looks like this
export const supportedLanguages = [
  {
    id: "en",
    title: "English",
    isDefault: true,
  },
  {
    id: "sv",
    title: "Swedish",
  },
  {
    id: "no",
    title: "Norwegian",
  },
];
Thanks for that. It seems to work for me when
alt_text
is inside of the
fields
array on image. It requires that an image be selected before the Edit details button becomes available.
Aha, yes now I understand! Can't believe I didn't try to upload one lol, Thank you
user A
πŸ‘
No problem! πŸ˜„

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?