Skip to content

Kirby 6.0.0

$field->toFile()

Returns a file object from a filename in the field

$field->toFile(): File|null

Return types

Kirby\Cms\Fileornull

Examples

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