Override file::url component

Trying to override the file component to serve files from the content folder directly to prevent copying to the media folder. I need it to work if the word “tiles” is anywhere in the URL. Tried this so far but doesn’t seem to work…


Kirby::plugin('hashandsalt/kirby-skip', [
    'components' => [
        'file::url' => function (Kirby $kirby, $file) {
          $page = $file->parent();
          if (preg_match('/tiles\/|tiles$/', $page->uri()) > 0) {
            return $kirby->url() . '/content/' . $page->diruri() . '/' . $file->filename();
          } else {
            return $file->mediaurl();

The file paths look a bit like this:


The only constant is the word “tiles”. I want to prevent anything under a “tiles” folder being copied to the media folder, regardless of depth.

Can these folders be anywhere in the tree? What is the max depth of the tree? Do they all share a main last parent (or is the common last parent the site object?)

The first bit is constant…


these pages all have a top level parent of “macros”. So along with that and the word “tiles” somewhere in the url, those are the concrete things to pick up on. Maximum depth is 5…


The depth is either 3 or 5…