Reference

Guide

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
$kirby Kirby\Cms\App

Kirby instance

$file Kirby\Cms\File

The original file object

Return type

string

Source code

kirby/config/components.php#L39