Error deleting image which has virtual page

Hi,

I have a gallery setup based on this solution: Virtual pages from image gallery | Kirby CMS. I am getting an error when trying to delete an image. Below are my models, and the error I am getting when deleting an image:

site/models/artwork.php (This is the gallery page)

<?php
class ArtworkPage extends Page
{
    public Pages|null $children = null;

    public function children(): Kirby\Cms\Pages
    {

        if ($this->children instanceof Pages) {
            return $this->children;
        }

        $images = [];


        if($image = $this->mainImage()->toFile()):
          $images[] = [
            'slug'     => $image->name(),
            'num'      => 0,
            'template' => 'lightbox-image',
            'model'    => 'lightbox-image',
          ];
        endif;
        
    
        if($this->additionalImages()->isNotEmpty()):
          foreach ($this->additionalImages()->toFiles() as $image) {
            $images[] = [
              'slug'     => $image->name(),
              'num'      => $image->sort()->value(),
              'template' => 'lightbox-image',
              'model'    => 'lightbox-image',
            ];
          }
        endif;

        return $this->children = Pages::factory($images, $this);
    }

}

site/models/lightbox-image.php (This is the individual image)

<?php

class LightboxImagePage extends Page
{
  public function image(string $filename = null): Kirby\Cms\File|null
  {
    if (!$filename) {
      return $this->parent()->images()->template('image')->findBy('name', $this->slug());
    }

    return parent::image($filename);
  }
}

site/blueprints/pages/artwork.yml

title: Artwork
icon: artwork
num: zero
create:
  title:
    label: Artwork title
    slug: "{{ page.title.slug }}"
options:
  cache: true
  changeTemplate: false
  move: false
status:
  draft: Draft
  listed: Published
tabs:
  content:
    label: Artwork
    icon: artboard
    columns:
      info:
        width: 1/1
        sections:
          main:
            type: fields
            fields:
              mainImage:
                type: files
                multiple: false
                type: files
                label: Main image
                uploads: image
                required: true
                query: page.images.filterBy('template','image')
                layout: cards
                width: 1/2
                size: full
                image:
                  back: white
                empty: Add a main image for this artwork
                help: This image is used on the Art & artists listing page, and is the first image on the individual artwork page. Click on the image to select a focal point
              additionalImages:
                type: files
                type: files
                label: Additional images
                uploads: image
                query: page.images.filterBy('template','image')
                layout: cards
                image:
                  back: white
                empty: Add additional images for this artwork
                help: Click on an image to select a focal point

When I delete an image file in the panel, I am getting a 500 error in the browser. The image file and the accompanying .txt file are being deleted, and the reference to the image in the content file is also being removed. I am not getting anything in the PHP error log in MAMP.

I have reproduced the issue in the plainkit. If anyone has any thoughts that would be super, I am stumped. Happy to send the example setup too if needed.

Thanks!

Could you DM me a download link to the example setup?