Skip to content

Kirby 4.1.2

$field->toFile()

Returns a file object from a filename in the field

$field->toFile(): Kirby\Cms\File|null

Return type

Kirby\Cms\File|null

Example

<?php if ($cover = $page->cover()->toFile()): ?>
<figure class="cover">
  <img src="<?= $cover->url() ?>" alt="<?= $cover->alt() ?>">
</figure>
<?php endif ?>