# Restrict selectable file-type in asset field

**URL:** <https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389>\
**Category:** Support\
**Created:** [November 9, 2018, 8:41am UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389 "2018-11-09T08:41:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nilsborg](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/nilsborg/32/138_2.png) [@nilsborg](https://discourse.getcockpit.com/u/nilsborg)\
**Post date:** [November 9, 2018, 8:41am UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389/1 "2018-11-09T08:41:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [November 9, 2018, 9:04am UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389/2 "2018-11-09T09:04:58Z")

</div>

You can’t restrict, which files are selectable, but you can restrict the upload via config.yaml.

```auto
# 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

```

---

<div class="post-metadata">

**Author:** ![alessandro92](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@alessandro92](https://discourse.getcockpit.com/u/alessandro92)\
**Post date:** [March 26, 2020, 1:59pm UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389/3 "2020-03-26T13:59:33Z")

</div>

Hi @nilsborg did you find a different solution?

---

<div class="post-metadata">

**Author:** ![Barcsix](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/barcsix/32/1527_2.png) [@Barcsix](https://discourse.getcockpit.com/u/Barcsix)\
**Post date:** [March 17, 2025, 10:17am UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389/4 "2025-03-17T10:17:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Barcsix](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/barcsix/32/1527_2.png) [@Barcsix](https://discourse.getcockpit.com/u/Barcsix)\
**Post date:** [January 19, 2026, 11:55am UTC](https://discourse.getcockpit.com/t/restrict-selectable-file-type-in-asset-field/389/5 "2026-01-19T11:55:21Z")

</div>

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 !
