Skip to content

Kirby 5.0.4

File URLs

Modify URLs for file objects

You can modify the URLs for file objects with our file::url component. This component is also responsible for building thumbnail URLs. This makes it very powerful. It can be used to let thumbnails be generated on different services like Cloudinary or Imgix, but it can also be used to host files in a different location and load them from there.

/site/plugins/file-urls/index.php
Kirby::plugin('my/fileUrls', [
    'components' => [
        'file::url' => function (Kirby $kirby, $file, array $options = []) {
            return 'https://cloudinary.com/...';
        }
    ]
]);

Parameters

Name Type Default Description
$kirbyrequired Kirby\Cms\App no default value
$filerequired Kirby\Cms\File no default value The original file object

Return type

string