Filepicker
A picker field that allows you to select one or more files out of a given set. A reference to this file is stored in the content file.
Field options
| Name | Type | Default | Description |
|---|---|---|---|
| autofocus | bool |
false
|
Sets the focus on this field when the form loads. Only the first field with this option gets focus |
| default | mixed |
null
|
Default value for the field, which will be used when a page/file/user is created |
| disabled | bool |
false
|
If true, the field is no longer editable |
| empty | arrayorstring |
null
|
The placeholder text if none have been selected yet |
| help | arrayorstring |
null
|
Optional help text below the field |
| image | arrayorstringorfalse |
null
|
Image settings for each item, a query string for the preview image or false to disable previews |
| info | string |
null
|
Info text for each item |
| label | arrayorstring |
no default value | The field label can be set as string or associative array with translations |
| layout | string |
'list'
|
Switch the layout of the items. Available layouts: list, cardlets, cards and table |
| link | bool |
true
|
Whether each item should be clickable |
| max | int |
null
|
Sets the maximum number of allowed items in the field |
| min | int |
null
|
Sets the minimum number of required items in the field |
| multiple | bool |
true
|
If false, only a single one can be selected |
| parent | string |
no default value | Query for the model whose files can be picked. By default, the files of the field's own model are used. |
| picker | array |
[]
|
Additional picker dialog props { image, layout, size } |
| query | string |
null
|
Query for the items to be included in the picker |
| required | bool |
false
|
If true, the field has to be filled in correctly to be saved. |
| search | bool |
true
|
Enable/disable the search field in the picker |
| size | string |
'auto'
|
Size for layout: cards. Available sizes: auto, tiny, small, medium, large, huge, full |
| store | string |
no default value | Whether to store uuid or id in the content file of the model |
| text | string |
null
|
Main text for each item |
| translate | bool |
true
|
Should the field be translatable? |
| uploads | mixed |
no default value | Sets the upload options for linked files: a blueprint name or blueprint and parent (template is an alias for blueprint) |
| validate | arrayorstring |
null
|
Additional validator rules for the value, e.g. email or ['minLength' => 3] |
| when | array |
null
|
Conditions when the field will be shown |
| width | string |
'1/1'
|
The width of the field in the field grid. Available widths: 1/1, 1/2, 1/3, 1/4, 2/3, 3/4 |
The filepicker field is basically a select/multiselect field specialized to allow you to select one or more files out of a given set of options. A reference to the selected file(s) is stored in the content file of the respective model (page, user, file). A filepicker field also allows you to upload files (not, however to delete or otherwise manipulate files, see also filelist field).

Example
fields:
downloads:
label: Downloads
type: filepicker
Limit the number of files
Min and max files
You can set the minimum/maximum number of files that can be selected:
fields:
downloads:
label: Select files...
type: filepicker
min: 1
max: 3
Multiple or single mode
If you only want to select a single file, set multiple mode to false (default is true).
fields:
downloads:
label: Select files...
type: filepicker
multiple: false
Layout
You can switch between list and cards layouts. Default is list layout.
fields:
downloads:
label: Select files...
type: filepicker
layout: cards
Querying files
The query option lets you limit the set of files that can be included. When not set, it defaults to all files of the current page.
Limit the set to images
gallery:
type: filepicker
query: page.images
You can use all file types available in Kirby here (images, documents, videos, audio, and code).
Querying files from other pages
If the query returns a site, page or user, the field lists the files of that model:
gallery:
type: filepicker
query: page.parent
You can get as complex as you like, e.g. get all images from all children of the photography page that use the cover template:
gallery:
type: filepicker
query: site.find('photography').children.images.filterBy('template', 'cover')
You can find more examples of how you can use the query language in the guide.
Image options
Apart from showing no image, any image options you use will only apply to the 'card' layout, but not to the 'list' layout.
ratio
A freely selectable image aspect ratio for various image styles such as movie trailers, movie posters, or simply portrait, landscape, square, etc.
image:
ratio: 16/9
cover
Whether or not the image will fill (cover) the available image space and not show banding for images that don't match your chosen image aspect ratio.
Options: true, false (default)
image:
cover: true
back
Set an image background behind the image, which will show if cover is not set to true as explained above.
Options: pattern (default), black, white
image:
cover: true
ratio: 1/1
back: black
No image
Don't want to see an image preview? Set the image options to false if you don't want to show an image, which reveals an icon instead:
image: false
Upload options
By default, the filepicker field allows you to upload files. You can define the Add button behavior with the uploads option: When clicking on the Add button, you can either select a file and/or upload a file (which is then automatically selected).
You can also drop files from your computer onto the open file picker dialog. They are uploaded and selected right away.
Prevent uploading
You can alternatively set the uploads property to false to prevent any file uploads:
gallery:
type: filepicker
uploads: false
Destination and template
By default, all files will be uploaded to the current page without any predefined template. But with the additional options, you can fetch files from anywhere, upload them to a specific page, or even control which file template should be assigned by default:
gallery:
type: filepicker
uploads:
parent: site
blueprint: files-upload
If you want to upload to the current page and only assign a template, you can directly assign it to the uploads property:
gallery:
type: filepicker
uploads: files-upload
Restricting uploads to certain file types
To restrict what types of files can be uploaded to the given destination, assign a file template using the uploads property, and in your file template, set the accept option. For more information see the docs about file blueprints.
Supported file types
By default, Kirby supports several files types.
To upload additional file types, you could register new file types with the fileTypes extension in a plugin.
Pagination
Options in the picker are paginated. You can set the number of items per pagination page in the picker using the limit property. The default setting is 20.
fields:
filepicker:
type: filepicker
label: Select an item
limit: 10
Search
The picker shows a search field by default. If you want to remove it, you can switch it off with the search option:
fields:
filepicker:
type: filepicker
label: Select an item
search: false
How to use in templates/snippets
Single file
To convert a single file to a file object, use the toFile() method:
<?php if ($image = $page->cover()->toFile()): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>
Multiple files
To work with or reference multiple files, create the group of files using the toFiles() method:
<?php
$images = $page->gallery()->toFiles();
foreach($images as $image): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endforeach ?>
Update programmatically
To change the field value from PHP, pass an array of file IDs or UUIDs to $page->update():
$page->update([
'downloads' => ['file://Kp0Vb2lm9Qe7Xs4R', 'blog/my-article/report.pdf']
]);
You can also pass a file object or a files collection, e.g. $page->files()->filterBy('extension', 'pdf').
Kirby stores the files as UUIDs (or as IDs, if you set the store option to id). Files that cannot be found are skipped.
To add a file to the existing selection, pass a callback:
$page->update([
'downloads' => fn ($downloads) => [...$downloads, 'file://Kp0Vb2lm9Qe7Xs4R']
]);