Skip to content

Kirby 3.9.8

$asset

Anything in your public path can be converted to an Asset object to use the same handy file methods as for any other Kirby files. Pass a relative path to the class to create the asset.

Details

You can create a new Asset object via the asset() helper or via the class constructor:

Via the helper

$asset = asset('assets/images/logo.svg');

Via the constructor

$asset = new Asset('assets/images/logo.svg');

With the object defined, you can then start calling the class's methods:

if ($asset->exists()) {
    echo $asset->width();
}