Files section to show only videos/images

I want to have two distinct file sections in my blueprint, one showing all images and the other showing videos only.
(how) can i query/filter by type in a file section, analogue to
$page->files()->filterBy('type', '==', 'video');

You cannot filter a section using a query or filterBy.

You can, however, assign a file template to the section, and in this file template, set the accept property.

Ok, thanks. That is quite hard to change for an existing site. I would need to manually edit all existing files’ blueprints to add a template (was using “default” up to this point…), or is there a better way for “migration”?

I recently wrote a simple route to automatically add a file template to all files:

return [
    'routes' => [
            'pattern' => 'imagetemplates',
            'action'  => function () {
                $result = '';
                foreach(site()->index() as $page) {
                    $result .= '<h2>' . $page->title() . '</h2>';
                    foreach($page->files() as $file) {
                        try {
                                'template' => 'default',
                            $result .= '<h3>' . $file->filename() . ' ✅</h3>';
                        catch(Exception $e) {
                            $result .= '<h3>' . $file->filename() . ' ❎</h3>';
                return $result;

You can adjust it to your liking.