Skip to content

Kirby 4.8.0

asset()

Helper to create an asset object

asset(string $path): Kirby\Filesystem\Asset

Parameters

Name Type Default
$path * string

Return type

Kirby\Filesystem\Asset

The asset() helper has access to the entire file system of your server as it is meant for flexible use and the provided paths can therefore not be validated by Kirby. Be careful about passing dynamic paths to it (especially paths that can be controlled from the request), as this may cause unexpected behavior or be abused by attackers.

Example

<?php if ($asset = asset('assets/images/logo.svg')): ?>
    <img src="<?= $asset->url() ?>" alt="">
<?php endif ?>