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?
Mar 25, 2021, 11:18 AM
how does your groq query look like?
Mar 25, 2021, 11:29 AM
Haven't got that far yet, I cant see it in the Sanity Studio:
Mar 25, 2021, 11:31 AM
but when i place the alt_text object outside of the image objects fields it works. Like this:
Mar 25, 2021, 11:32 AM
        {
            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",
        },
    ],
Mar 25, 2021, 11:32 AM
Then it looks like it should except that its not nested:
Mar 25, 2021, 11:33 AM
Not really a big problem but was curious to why this is πŸ™‚
Mar 25, 2021, 11:36 AM
Hi User. What does the schema for your
localeString
look like?
Mar 25, 2021, 1:49 PM
Hi! it looks like this:
Mar 25, 2021, 1:49 PM
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",
  })),
};
Mar 25, 2021, 1:50 PM
And supportedLanguages looks like this
export const supportedLanguages = [
  {
    id: "en",
    title: "English",
    isDefault: true,
  },
  {
    id: "sv",
    title: "Swedish",
  },
  {
    id: "no",
    title: "Norwegian",
  },
];
Mar 25, 2021, 1:50 PM
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.
Mar 25, 2021, 1:58 PM
Aha, yes now I understand! Can't believe I didn't try to upload one lol, Thank you
user A
πŸ‘
Mar 25, 2021, 2:01 PM
No problem! πŸ˜„
Mar 25, 2021, 2:01 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.

Was this answer helpful?