$files->filterBy()
Alias for Kirby\Toolkit\Collection::filter
$files->filterBy(mixed $args = null): Kirby\Cms\FilesParameters
| Name | Type | Default | 
|---|---|---|
| $args | mixed | null | 
Return type
This method does not modify the existing $files object but returns a new object with the changes applied. Learn more →
Parent class
  Kirby\Cms\Files    inherited from Kirby\Toolkit\Collection  
Values for $args
$args can be a string, true, false or a combination of a filter method and an argument. In case of the in or not in filters, the third argument must be an array.
Examples
// filter by extension
$images = $page->images()->filterBy('extension', 'jpg');
// filter by custom field value
$images = $page->images()->filterBy('gallery', 'gallery-2');
// filter by filenames containing a string
$files = $page->files()->filterBy('filename', '*=', '-document');
// filter all types except documents
$files = $page->files()->filterBy('type', '!=', 'document');
// filter all files that have a template assigned
$files = $page->files()->filterBy('template', true);Available filter methods
| Method | Function | 
|---|---|
| == | all values that match exactly | 
| != | all values that don't match | 
| in | takes an array as parameter, matches all values that are included in the array | 
| not in | takes an array as parameter, matches all values that are not included in the array | 
| > | all values that are greater than the given value | 
| >= | all values that are greater or equal the given value | 
| < | all values that are smaller than the given value | 
| <= | all values that are smaller or equal the given value | 
| *= | all values that contain the given string | 
| !*= | all values that don't contain the given string | 
| ^= | all values that start with the given string | 
| !^= | all values that don't start with the given string | 
| $= | all values that end with the given string | 
| !$= | all values that don't end with the given string | 
| * | all values that match the given regular expression | 
| !* | all values that don't match the given regular expression | 
| betweenor.. | takes an array as parameter with two parameters; first is the min value, second is the max value | 
| maxlength | all values that have the given maximum length | 
| minlength | all values that have the given minimum length | 
| maxwords | all values that have the given maximum amount of words | 
| minwords | all values that have the given minimum amount of words | 
| date ==(added in 3.4.0) | all date values that exactly match the given date string | 
| date !=(added in 3.4.0) | all date values that don't match the given date string | 
| date >(added in 3.4.0) | all date values that are later than the given date string | 
| date >=(added in 3.4.0) | all date values that are later or equal the given date string | 
| date <(added in 3.4.0) | all date values that are earlier than the given date string | 
| date <=(added in 3.4.0) | all date values that are earlier or equal the given date string | 
| date betweenordate ..(added in 3.4.0) | all date values that are between the given date strings |