# File blueprint

File blueprints are located in `/site/blueprints/files` and control the Panel setup and form fields for individual file types.

****

- Read more: <https://getkirby.com/docs/guide/blueprints/introduction>

****

In each <a href="https://getkirby.com/docs/reference/panel/sections/files">files section</a> you can use the `template` option to determine which template will be used for each file within that section. For example, you can create a files section to which users can only upload images and which have a given set of fields, and another section for PDF files with another set of fields.

## Blueprint location

```filesystem
/site/blueprints/files/
```

## Default file blueprint

To create the same set of fields for all file types, you can setup a `default.yml` that is used whenever no custom file template is configured.

```filesystem
/site/blueprints/files/default.yml
```

## Title

The title is required. It will appear in the file view to indicate the selected template for the current file.

```yaml
title: Project Image
```

### Translated titles

The title can be translated by passing an array of translations with the matching language code as key:

```yaml
title:
  en: Project Image
  de: Projekt Bild
```

##  Accept

The `accept` option defines a set of rules which should be validated whenever a file with this type is created. This is perfect to allow only certain MIME types or file extensions, or check for the file size and the image dimensions.

<info>
If no type restrictions (`extension`, `mime` or `type`) are defined in the file blueprint, Kirby will limit the accepted uploads to the types `image`, `document`, `archive`, `audio` and `video` by default. This protects your site against unexpected uploads like code files that could be used to attack the server or the visitors' browsers.
</info>

The `accept` option can either be a simple string for a list of accepted MIME types, or an array of multiple accept validation rules:

### Simple

```yaml
accept: image/jpeg, image/png
```

### Extended

```yaml
accept:
  extension: jpg, png
  maxheight: 200
  orientation: landscape
```

| Option | Value |
| ------ | ----- |
| `extension` | comma-separated `string` or `array` |
| `mime` | e.g. `image/jpeg`, comma-separated or `array` |
| `maxheight` | `int` in `px` |
| `maxsize` | `int` in `bytes` |
| `maxwidth` | `int` in `px` |
| `minheight` | `int` in `px` |
| `minsize` | `int` in `bytes` |
| `minwidth` | `int` in `px` |
| `orientation` | `landscape`/`square`/`portrait` |
| `type` | comma-separated `string` or `array` |

You can combine the `extension`, `mime` and `type` checks. If a `mime` type is specified, the `extension` and `type` options are ignored for the browser. Extensions and types, however, are still used to validate an uploaded file on the server. All constraints need to match for a file to be valid.

If you don't set the `mime` option, the valid MIME types for the frontend upload input are auto-detected from the configured `extension` or `type` options as well as the default Kirby file types. If the intersection is empty, an empty string is used for the accept attribute in the uploader.

You can however override this behavior by setting the `mime` option as well, for example to define MIME types that are compatible with all browsers while still protecting the uploads based on the extension and/or file type:

```yaml
accept:
  mime: image/*
  type: image
```

In this example, Kirby will generate a file upload input with an `accept="image/*"` attribute and will then validate both the MIME type and the detected file type on the server after the file is uploaded.

### Allow all file types

If you want to allow the upload of any file type (including code files), you can disable Kirby's default upload type restriction like this:

```yaml
accept: true

# or:
accept:
  mime: null
  orientation: square
  ...
```

<warning>
Please only allow all uploads if all Panel users can be trusted completely as it will be possible to upload files that could be used to attack the server or the visitors' browsers.
</warning>

## En-/disable setting focus in Panel

By default, setting the focus point in the Panel is enabled for all viewable images with a Panel preview and disabled for all other files.

When a focus point is set, it will be used automatically when you crop an image.

You can change this via the `focus` option in the file's blueprint:

```yaml "site/blueprints/files/image.yml"
focus: false
```

## Optimize uploaded images: `create`

In your file blueprints you can set resize and crop settings, which will be applied directly after the upload. This is great to avoid huge original files in the content folder.

```yaml "site/blueprints/files/image.yml"
title: Image
create:
  width: 500
  height: 500
  crop: true
```

### Convert image formats on upload

The `create` option also allows you to define a target image format. Images uploaded in other formats (e.g. `.jpg` or `.png`) will be converted to the target format right after the upload.

```yaml "site/blueprints/files/image.yml"
create:
  format: webp
```

If the file blueprint also accept non-image files, those will be skipped and their format/extension left untouched.

### Strip image metadata

Image files can (and often do) carry so called EXIF metadata such as the date and time the image was taken, the camera make and model and the GPS geolocation. Especially the geolocation can be considered personal data and can be a risk to vulnerable individuals when published online.

If the `create` option is enabled with any configuration, all newly uploaded images are passed through Kirby's thumb engine, which strips all metadata by default. If you only need the metadata stripping, you can enable it like so:

```yaml "site/blueprints/files/image.yml"
create:
  strip: true
```
<info>
Please keep in mind that it is *not* possible to disable the stripping by setting the option to `false`. We will add this option in the future to add more control e.g. for use cases where you intend to work with the EXIF data on the site but still want to set other options to convert the format or reduce the image dimensions.
</info>

## `image` options

The (preview) `image` blueprint option defines how any file with this blueprint will be presented, e.g. in a files section.

### `back`

Sets the image background.

```yaml

image:
  cover: true
  ratio: 1/1
  back: black
```

#### Examples

| `back: pattern` | `back: black` | `back: white` |
| -   | -   | -   |
| <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/c607b0eeeb-1717846665/pattern.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/7ff0b4f036-1717846665/black.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e8fc5d8123-1717846665/white.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> |

#### Custom colors
The `back` and `color` options for also support shorthands for the core CSS color variables as well as HEX codes or other native CSS color properties (e.g. even gradients).

```yaml
image:
  back: "purple-400"
```
Check out the <a href="https://lab.getkirby.com/public/lab/basics/design/colors">list of our color properties</a> for available options.

```yaml
image:
  back: "#ff0000"
```

```yaml
image:
  back: "linear-gradient(90deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 35%, rgba(0,212,255,1) 100%)"
```

#### Support for queries

This option also support our powerful queries:

```yaml
image:
  back: "{{ file.myCustomBackColor }}"
```

### `color`

Sets the icon color.

```yaml
image:
  query: false
  color: red-200
```

### `cover`

Whether or not the image will cover the available space.
Options: `true`, `false (default)`

```yaml
image:
  cover: true
```

#### Examples

| `cover: true` | `cover: false` |
| -   | -   |
| <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/8c6a0ebaa1-1717846665/cover.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/11f81e5a6b-1717846665/no-cover.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> |

### `ratio`

A freely selectable image ratio

```yaml
image:
  ratio: 16/9
```

#### Examples

| `ratio: 2/3` | `ratio: 1/1` | `ratio: 3/2` | `ratio: 16/9` |
| -   | -   | -   | -    |
| <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0"><img alt="" class="rounded" height="471" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ca5ae35d20-1717846665/2by3.png?width=277&amp;height=471&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0"><img alt="" class="rounded" height="333" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/3edbb67171-1717846665/1by1.png?width=277&amp;height=333&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0"><img alt="" class="rounded" height="240" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/e257211c4e-1717846665/3by2.png?width=277&amp;height=240&amp;enlarge=0 1848w" width="277"></a></figure> | <figure class="image"><a data-lightbox href="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0"><img alt="" class="rounded" height="211" loading="lazy" sizes="auto" src="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0" srcset="https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0 462w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0 690w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0 924w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0 1380w, https://assets.getkirby.com/media/pages/docs/reference/panel/blueprints/file/ccce485243-1717846665/16by9.png?width=277&amp;height=211&amp;enlarge=0 1848w" width="277"></a></figure> |

<info>
You are not limited to the example ratios above. In fact, Kirby calculates the ratio for you as long as you enter it in the format **`a/b`**
</info>

### `query`

Query an image to show as preview, for example, another version of the image, or a preview image for a PDF or video file.

```yaml

image:
  query: page.images.findBy("name", "preview")
  cover: true
  ratio: 1/1
  back: black
```

## Options

With options, you can control all the file actions that should or should not be available for this particular file type. The option dropdown for files will adjust accordingly.

| Option | Value |
| ------ | ----- |
| `changeName` | `true`/`false` |
| `changeTemplate` | `true`/`false` |
| `delete` | `true`/`false` |
| `read` | `true`/`false` |
| `replace` | `true`/`false` |
| `update` | `true`/`false` |

<p>Each option can be set on a per user role for fine-grained permissions, for example:</p>
<figure class="code">
<pre><code class="language-yaml">options:
  delete:
    admin: true
    editor: false</code></pre>
</figure>
<p>Or using a wildcard to change the default for all roles:</p>
<figure class="code">
<pre><code class="language-yaml">options:
  update:
    *: false
    editor: true</code></pre>
</figure>
<p>Controlling accessibility for roles.</p>
<figure class="code">
<pre><code class="language-yaml"># Page is not accessible and not visible for all roles except admins.
options:
  access:
    *: false
    admin: true
  list:
    *: false
    admin: true</code></pre>
</figure>

<details class="since list-none" open="1">
<summary >
	Since <a href="https://github.com/getkirby/kirby/releases/tag/5.0.0">5.0.0</a></summary>
<div>
	<h2 id="view-buttons"><a href="#view-buttons" tabindex="-1">View buttons</a></h2>
<p>Kirby allows you to define what buttons to use for this file. To select which (default) buttons to show on a particular view you can set the <code class="type">buttons</code> option in the corresponding blueprint:</p>
<figure class="code">
<pre><code class="language-yml">buttons:
  settings: true</code></pre>
</figure>
<p>By setting the value to <code class="type type-bool">true</code>, you can reference existing buttons (from the <a href="https://getkirby.com/docs/reference/system/options/panel/panel-view-buttons#referencing-buttons">core or <code class="type">config.php</code> file</a> or even <a href="https://getkirby.com/docs/reference/plugins/extensions/panel-view-buttons">Panel area plugin extensions</a>) by name and decide which ones to include and in what order.</p>
<h3 id="view-buttons__create-a-new-button"><a href="#view-buttons__create-a-new-button" tabindex="-1">Create a new button</a></h3>
<p>You can now also define your own custom buttons directly in a blueprint:</p>
<figure class="code">
<pre><code class="language-yml">buttons:
  settings: true
  social:
    icon: mastodon
    text: Mastodon
    link: "https://mastodon.social/@getkirby"
    theme: purple-icon</code></pre>
</figure>
<p>The available options are based on the <a href="https://lab.getkirby.com/public/lab/docs/k-view-button"><code class="type">k-view-button</code> component</a>. Check out the <a href="https://getkirby.com/docs/reference/system/options/panel/panel-view-buttons">config option documentation</a> for more details, e.g. in regard to available attributes or query support.</p>
<h3 id="view-buttons__disable-all-buttons"><a href="#view-buttons__disable-all-buttons" tabindex="-1">Disable all buttons</a></h3>
<figure class="code">
<pre><code class="language-yml">buttons: false</code></pre>
</figure></div>
</details>

## Examples

You can find examples of file blueprints in the <a href="https://getkirby.com/docs/reference/panel/samples/file">samples section</a>.