# File types

****

Kirby categorizes file types by extension and MIME type. We support a wide range of file types, but of course we cannot predefine them all. You can add your own file types to the system.

## Registering a new file type

New file types can be defined in plugins. The array key represents the file extension. Define the matching MIME type and file type category like this:

```php
Kirby::plugin('your/plugin', [
  'fileTypes' => [
    'm4p' => [
      'mime' => 'video/m4p',
      'type' => 'video',
    ],
  ]
]);
```

Kirby will now recognize `m4p` files by filename and by MIME type. `$file->type()` will now return `video` for such files and they will also be included in the `$page->videos()` collection. Of course you can now also find them by using `$page->files()->filterBy('type', 'video')`.

`type` can be `audio`, `code`, `document`, `image` and `video` (see <a href="https://getkirby.com/docs/guide/files/files#supported-file-types">Kirby file types</a>). For the `mime` attribute, you can explore <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types">a list of common MIME types</a>.

## Image processing

If you want to make your new file type available for image processing, you can set the `resizable` attribute. It still depends on the thumb driver or your image processing API if it can handle the file type though, but Kirby will now give it a try.

```php
Kirby::plugin('your/plugin', [
  'fileTypes' => [
    'heif' => [
      'mime'      => ['image/heic', 'image/heif'],
      'type'      => 'image',
      'resizable' => true,
    ]
  ]
]);
```

## Image previews

If your new file type should get a preview in the Panel file view, you can set the `viewable` option. It depends on the browser if it can actually display the file inline.

```php
Kirby::plugin('your/plugin', [
  'fileTypes' => [
    'heif' => [
      'mime'      => ['image/heic', 'image/heif'],
      'type'      => 'image',
      'resizable' => true,
      'viewable'  => true
    ]
  ]
]);
```