Reference

Guide

$files->findBy()

Find a single element by an attribute and its value

$files->findBy(string $attribute, mixed $value): mixed

Parameters

Name Type Default Description
$attribute string
$value mixed

Return type

mixed

Example

<?php
if($file = $page->files()->findBy('filename', 'myfile.jpg')) {
  echo $file->url();
?>

Source code

kirby/src/Toolkit/Collection.php#L371