getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Files: `accept` not working #5057

Closed nelhop closed 1 year ago

nelhop commented 1 year ago

Description

The accept option to restrict file types is not working. All images can be selected.

# /site/blueprints/site.yml
fields:
  image:
    type: files
    accept:
      mime: image/svg+xml
      extension: svg

Expected behavior
Only svg files should be possible to upload or select.

Kirby Version 3.9.1

afbora commented 1 year ago

accept prop works for file blueprint (for ex: /site/blueprints/files/svg.yml) not for files field: https://getkirby.com/docs/reference/panel/fields/files#upload-options__restricting-uploads-to-certain-file-types

# /site/blueprints/pages/default.yml
fields:
  image:
    type: files
    uploads: svg # refers to `/site/blueprints/files/svg.yml`
# /site/blueprints/files/svg.yml
accept:
    mime: image/svg+xml
    extension: svg
nelhop commented 1 year ago

Thanks for clarifying @afbora!

So there is no way to restrict the file type which can be selected, only the one that is uploaded?

afbora commented 1 year ago
# /site/blueprints/pages/default.yml
fields:
  image:
    type: files
    uploads: svg # refers to `/site/blueprints/files/svg.yml`
    query: page.images.filterBy('extension', 'svg')