# Image Metadata (/docs/components/image-metadata)



<ComponentPreview name="image-metadata" />

## Installation [#installation]

<Tabs items="[&#x22;Command&#x22;, &#x22;Manual&#x22;]">
  <Tab value="Command">
    <CodeBlockTabs defaultValue="npm">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="npm">
          npm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="pnpm">
          pnpm
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="yarn">
          yarn
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="bun">
          bun
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="npm">
        ```bash
        npx shadcn@latest add @uploadcn/image-metadata
        ```
      </CodeBlockTab>

      <CodeBlockTab value="pnpm">
        ```bash
        pnpm dlx shadcn@latest add @uploadcn/image-metadata
        ```
      </CodeBlockTab>

      <CodeBlockTab value="yarn">
        ```bash
        yarn dlx shadcn@latest add @uploadcn/image-metadata
        ```
      </CodeBlockTab>

      <CodeBlockTab value="bun">
        ```bash
        bun x shadcn@latest add @uploadcn/image-metadata
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Tab>

  <Tab value="Manual">
    Install [Upload](/docs/components/upload) and the shadcn `badge`, `input`, `textarea` components, then copy:

    <ComponentSource name="image-metadata" />
  </Tab>
</Tabs>

## Usage [#usage]

```tsx
import { ImageMetadataUpload } from "@/components/image-metadata"
```

```tsx
<ImageMetadataUpload
  onSave={(images) =>
    images.map(({ item, alt, caption }) => ({
      key: item.result?.key,
      alt,
      caption,
    }))
  }
/>
```

Alt text and captions are stored on each item's `meta` with `uploader.update(id, { meta })`, so they survive re-renders and travel with the item.

## Props [#props]

<TypeTable
  type="{
  adapter: {
    type: &#x22;UploadAdapter&#x22;,
    default: 's3Adapter({ endpoint: &#x22;/api/upload&#x22; })',
    description: &#x22;Where files go.&#x22;,
  },
  uploader: {
    type: &#x22;Uploader&#x22;,
    description: &#x22;An uploader from `useUploader`, instead of options.&#x22;,
  },
  maxFiles: { type: &#x22;number&#x22;, default: &#x22;8&#x22; },
  requireAlt: {
    type: &#x22;boolean&#x22;,
    default: &#x22;true&#x22;,
    description: &#x22;Require alt text before saving.&#x22;,
  },
  onSave: { type: &#x22;(images: { item, alt, caption }[]) => void&#x22; },
  className: { type: &#x22;string&#x22; },
}"
/>
