# Image

Picks or uploads an image from a [media library](/configuration/media/) and stores its public path. The field needs a media library; without one it shows an error instead of a picker.

Add this field under `fields` in `.pages.yml`:

```yaml
- name: cover
  type: image
```

A saved value in YAML or Markdown front matter might look like:

```yaml
cover: /uploads/cover.jpg
```

For a gallery:

```yaml
- name: gallery
  type: image
  options:
    multiple: { max: 12 }
    unique: true
```

A saved value in YAML or Markdown front matter might look like:

```yaml
gallery: [/uploads/a.jpg, /uploads/b.jpg]
```

Previews in SP CMS may use temporary URLs; only the public path is saved. A saved path must be inside the field's media library, so links to images on other websites are rejected.

## Options

| Option       | Description                                                                                                                                  |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `media`      | The `name` of the [media library](/configuration/media/) to use. Defaults to the first library.                                              |
| `path`       | Folder to open first, as a repository path inside the library's `input`, such as `public/uploads/covers`.                                    |
| `multiple`   | `true`, or `{ min, max }`, to allow several images, stored as a list.                                                                        |
| `unique`     | With `multiple`, `true` to prevent picking the same image twice.                                                                             |
| `rename`     | Rename uploads: `false`, `safe` (or `true`) or `random`. Overrides the library's setting.                                                    |
| `extensions` | Allowed extensions, such as `[jpg, png, webp]`. Narrows what the library allows; see [field settings](/configuration/media/#field-settings). |
