Merging local and virtual files

Hello everyone,
I’d like to merge virtual and local files (from the file system). For the virtual files of my pages I followed this cookbok and it is working just fine. I can see all external files and use them in my content structure. But the panel ist getting kind of slow when external images are queried as page preview thumbs. This should be the case to make content editing easier.

So, not beeing a programmer at all, I thougt I simply use local files for all the page thumbs in Kirby (which will be then optimized, scaled etc. by Kirby wihtin the media folder) and merge these with the external/virtual files in files sections of my pages.

Local files and virtual files should have different file blueprints, because I’d like to provide files fields for these based on the templates.

Can anoyone point me in a direction to start here? I read the guide on merging content sources, but do not know how to transfer to files.

Thank you!

Not sure I quite understand. So you want to download the external files to be able to use them as local files? Why would you need the virtual files in this case?

I have external files for each page and use them within the editing process and select them in different fields of each page. For this, I only need to “see” available images in the panel, which works great so far. The file upload to the external source is part of another process and is not done via the panel. At the moment, Kirby is only the backend for content authoring; i make static sites from quite specific json representations later and have image references here, not the images itself.

To make it easier to find content in the panel, I normally use cardlet previews for pages with a selected image for each page. These images a now also coming from the external source and when I have a lot of pages, the panel needs quite some time to render my page overview.

So I thougt to add one image per page as a local file via upload. Another way would be to provide an additional smaller thumb for each page as a virtual file, too. But I was curios how to merge to file sources.

In the Page model where you overwrite the the files method, you would add the local files to the virtual files. You can access them with parent::files().

Thank you. Do I need to loop over the files object parent::files and then attach one by one to a new array for the local files which I then will merge with the external files ($filesCollection in the cookbook)?

Not tested, but I would expect this to work:

$filesCollection = $filesCollection->add(parent::files);
return $this->files = $filesCollection;

Okay, that was easy. Thank you!