Reference

Guide

$files

The $files object extends the general Collection class and refers to a collection of files, i.e. images, documents etc. Files can be filtered, searched, converted, modified or evaluated with the following methods:

How to get a files object

Before you can use the methods of the $files class, you need a $files object. To get a files object, you fetch the files you need from the $site, $page or $user object:

Site files

$files = $site->files();

Page files

$files = $page->files();

User files

$files = $user->files();

Examples:

With the $files object defined, you can now do all sorts of things:

Filter files

$filteredFiles = $files->filterBy('template', 'cover');

Group files

$groupedFiles = $files->groupBy('template');

Get the first file of the collection

$firstFile = $files->first();

Only get three files

$files = $files->limit(3);