# Files methods

****

Files methods are registered with the `filesMethods` extension.

## Default files methods

**For a full <a href="https://getkirby.com/docs/reference/#files">list of default files methods</a>, please check out the Reference.**

<info>Be aware that you cannot override these default files methods with any custom files method.</info>

## Getting started

You can extend the set of defined files methods very easily in a plugin file.

```php "/site/plugins/files-methods/index.php"
Kirby::plugin('my/plugin', [
    'filesMethods' => [
        'listAll' => function () {
            foreach($this as $file) {
                echo '- ' . $file->filename() . '<br>';
            }
        }
    ]
]);
```

This example shows the basic architecture of a files method. You define the method name with the key for the `filesMethods` extension array. `$this` in the callback function is the `$files` object.

## Working with method arguments

In some cases it might be helpful to be able to pass arguments to the method:

```php
<?php if ($files->moreThan($num)): ?>
  Page has more then $num files.
<?php endif ?>
```

The definition for such a method with arguments is very simple:

```php
Kirby::plugin('my/plugin', [
    'filesMethods' => [
        'moreThan' => function ($num) {
            return $files->count() > $num;
        }
    ]
]);
```