Preview image from assets folder doesn't seem to work with svg

The pages#Preview images example loading an image from the asset folder doesn’t seem to work with svg images.
It results in panel error message:

The section “sectionname” could not be loaded: The file::version component must return a File or FileVersion object

I reproduced it using a fresh starterkit:

  1. put an svg in assets/images/test.svg
  2. load that svg in model/album.php:
class AlbumPage extends Page
{
    public function cover()
    {
        return new Asset('assets/images/test.svg');
    }
}

Result:

image

Seems that a svg asset doesn’t inherit from Kirby\Cms\FileVersion or Kirby\Cms\File.

From your title I assume that it does work with other file types, though?

Thanks for your quick response, Sonja. Yes it works with jpgs like in the example and I also tested it successfully with a png.

Could you please create an issue on GitHub? Can’t test now and don’t want this to get lost.

Ok, issue created: https://github.com/getkirby/kirby/issues/2746

The bug was solved Preview image from assets folder doesn’t seem to work with svg · Issue #2746 · getkirby/kirby · GitHub