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…
<?php
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:
/content/subpage/anothersubpage/somerandomname.tiles/l1/0001/ajpegfile.jpg
/content/subpage/anothersubpage/tiles/l1/0001/00002.jpg
/content/subpage/anothersubpage/somerandomname.tiles/preview.jpg
/content/subpage/anothersubpage/tiles/preview.jpg
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.