Is it possible to use an external url as cover image for a page?

I’ve created virtual pages from the YouTube-API and I would like to display the thumbnails in the control panel.

At the moment, I have this:

foreach($results as $key => $video) {
    $pages[] = [
        'slug'	=> $video->contentDetails->videoId,
        'num'	=> $key+1,
        'template' => 'video',
        'model'	=> 'video',
        'content' => [
           'image' => $video->snippet->thumbnails->default->url,
           'title' => $video->snippet->title
        ]
    ];
}

And now I’d like to use “page.content.image” as image source.
I know there’s a way to create virtual files ( Virtual Files for page? - Kirby 3 / Solved :white_check_mark: - Kirby (getkirby.com), but I just want to display the thumbnails.

You would indeed have to create a virtual image object from the thumb url.

I think for your use case it would be best to create a custom cover method that returns a virtual file object from the url.

Note that for display in the Panel, it’s necessary that you also use a file::version component:

Example in page model:

  public function cover()
  {
    return File::factory([
      'filename' => 'abc.jpg',
      'template' => 'virtual-file',
      'url'      => 'https://images.unsplash.com/photo-1622461916756-96452ce31a92?ixid=MnwyMzY4NjZ8MHwxfGFsbHwyfHx8fHx8Mnx8MTYyMjk3Mzg1Mg&ixlib=rb-1.2.1'
    ], $this);
  }

Then use cover method in pages section and add the file::version component in a plugin, example in uncoming recipe:

Line 204ff.