Skip to content

Kirby 3.9.8

$site->image()

Returns a specific image by filename or the first one

$site->image(?string $filename = null): Kirby\Cms\File|null

Parameters

Name Type Default
$filename string|null null

Return type

Kirby\Cms\File|null

Parent class

Kirby\Cms\Site

Example

Fetching the first image

<?php if($image = $site->image()): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>

Fetching a specific image

<?php if($image = $site->image('myimage.jpg')): ?>
<img src="<?= $image->url() ?>" alt="">
<?php endif ?>