Media Picker
The media picker formfield allows you to upload/delete/select files directly from the media-manager. You can customize the behaviour with the following options:
1
{
2
"max": 10,
3
"min": 0,
4
"expanded": true,
5
"show_folders": true,
6
"show_toolbar": true,
7
"allow_upload": true,
8
"allow_move": true,
9
"allow_delete": true,
10
"allow_create_folder": true,
11
"allow_rename": true,
12
"allow_crop": true,
13
"allowed": [],
14
"hide_thumbnails": false,
15
"quality": 90,
16
"watermark": {
17
"source": "...",
18
"position": "top-left",
19
"x": 0,
20
"y": 0
21
}
22
}
Copied!
Name
Description
Type
Default
base_path
The start path relative to the filesystem
String
/bread-slug/
rename
Rename uploaded files to a given string/expression
String
Original name
delete_files
Delete files if the BREAD entry is deleted.
Use with caution!
bool
false
show_as_images
Shows stored data as images when browsing
bool
false
min
The minimum amount of files that can be selected
int
0
max
The maximum amount of files that can be selected.
0 means infinite
int
0
expanded
If the media-picker should be expanded by default
bool
true
show_folders
Show subfolders
bool
true
show_toolbar
Shows/hides the whole toolbar
bool
false
allow_upload
Allow users to upload new files
bool
true
allow_move
Allow users to move files/folders
bool
true
allow_delete
Allow users to delete files
bool
true
allow_create_folder
Allow users to create new folders
bool
true
allow_rename
Allow users to rename files.
Use with caution!
bool
true
allow_crop
Allow users to crop images
bool
true
hide_thumbnails
Hides known thumbnails and shows them as children of the parent image
bool
true
quality
Sets the quality of uploaded images and thumbnails
int
90
allowed
The allowed types to be uploaded/selected.
Empty object means all types.
Files with other types won't be displayed.
Object
[]

Allowed types

If you want your users to only be able to upload specific file-types you can do so by passing an object with mime-types to the `allowed` prop, for example:
1
["image", "audio", "video"]
Copied!
or
1
["image/jpeg", "image/png", "image/bmp"]
Copied!

Expressions

The base_path and rename can contain the following placeholders:
  • {pk} the primary-key of the entry (only for base_path)
  • {uid} the user-id of the current logged-in user
  • {date:format} the current date in the format defined in format. For example {date:d.m.Y}
  • {random:10} random string with N characters
So a base_path can, for example, look like the following:
1
{
2
"base_path": "/my-bread/{pk}/{date:Y}/{date:m}/"
3
}
Copied!

Watermark

A watermark can be added to uploaded images. To do so, you need to define a source property relative to Voyagers storage-disk. There are a few optional arguments you can use: position the position where the watermark is placed. Can be:
  • top-left (default)
  • top
  • top-right
  • left
  • center
  • right
  • bottom-left
  • bottom
  • bottom-right
x Relative offset to the position on the x-axis. Defaults to 0
y Relative offset to the position on the y-axis. Defaults to 0
size the size (in percent) of the watermark relative to the image. Defaults to 15

Thumbnails

You can generate thumbnails for each uploaded image. A thumbnail can be one of three types:

Fit

Fit combines cropping and resizing to find the best way to generate a thumbnail matching your dimensions. You have to pass width and can pass height and position. An example for fit would be:
1
{
2
"thumbnails": [
3
{
4
"type": "fit",
5
"name": "fit-500",
6
"width": 500, // Required
7
"height": 500, // Optional
8
"position": "center" // Optional. Refer to http://image.intervention.io/api/fit
9
}
10
]
11
}
Copied!

Crop

Crop an image by given dimensions and position. You have to pass width and height and can pass x and y. An example for crop would be:
1
{
2
"thumbnails": [
3
{
4
"type": "crop",
5
"name": "crop-500-500",
6
"width": 500, // Required
7
"height": 500, // Required
8
"x": 50, // Optional. Left offset
9
"y": 50, // Optional. Top offset
10
}
11
]
12
}
Copied!

Resize

Resize the image to the given dimensions. You have to pass width and/or height. Some examples for resize:
1
{
2
"thumbnails": [
3
// Width will be 500px, height will be calculated based on the aspect-ratio
4
{
5
"type": "resize",
6
"name": "resize-500",
7
"width": 500,
8
"upsize": true, // Optional. Set to false to prevent upsizing
9
},
10
// Resizes the image to 500x500px
11
{
12
"type": "resize",
13
"name": "resize-500-500",
14
"width": 500,
15
"height": 500
16
},
17
// Height will be 500px, width will be auto-calculated
18
{
19
"type": "resize",
20
"name": "resize-500",
21
"width": null,
22
"height": 500
23
}
24
]
25
}
Copied!
A watermark can also be inserted into each thumbnail. Just define the watermark-options on the parent and set watermark to true for each thumbnail you want to insert the watermark to.
Last modified 1mo ago
Export as PDF
Copy link