Hello!
quick question: is it possible to restrict the file-type which can be selected by the user in an asset field? Like: only jpg and png. Or only pdf…
Thanks!
Hello!
quick question: is it possible to restrict the file-type which can be selected by the user in an asset field? Like: only jpg and png. Or only pdf…
Thanks!
You can’t restrict, which files are selectable, but you can restrict the upload via config.yaml.
# define allowed file types for uploads (global)
assets.allowed_uploads: png, jpg, jpeg
# define allowed file types for uploads (for user groups)
groups:
author:
$admin: false
$vars:
assets.allowed_uploads: png, jpg, jpeg
Hi @nilsborg did you find a different solution?
Hello, is there any solution to achieve this ? I just wanna restrict one asset field of my model so it accepts only jpg, jpeg, png.
If you’re looking for a way to apply this kind of filter, i found that it works like this :
On your assets field, click the “options” tab, then insert the filter you need.
For images :
{
filter: {
type: 'image'
}
}
For videos :
{
filter: {
type: 'video'
}
}
For pdf :
{
filter: {
mime: 'application/pdf'
}
}
Multiple types :
{
filter: {
$or: [
{ type: 'image' },
{ mime: 'application/pdf' }
]
}
}
Hope it helps !