How to create virtual pages for each photo in an album?

Basically as described here: https://getkirby.com/docs/guide/virtual-pages/content-from-csv

In the album model, you would define the children, so each image would become a page

(note that you can’t use the filename as slug, because that would redirect to the media folder.

class AlbumPage extends Page
{

    public function children()
    {
        $images = [];

        foreach ($this->images() as $image) {
            $images[] = [
                'slug'     => $image->name(), // this could potentially result in errors if images have the same name but different extension and/or if filenames are not sanitized on upload
                'num'      => 0, // or use the image sort number here if available
                'template' => 'image',
                'model'    => 'image',
               // 'content'  => $image->content()->toArray() // you can set the image content to the page content, but maybe you don't want or need that because you can directly get the meta data content from the file
            ];
        }

        return Pages::factory($images, $this);
    }

}

(Maybe store a sluggified version of the filename in the file metadata on file upload, so that can be used for the slug and also to find the image)

Then in the child model, you might want to redefine the image method, but it is probably not necessary. In the image.php template, you could get the file object like this:

<?php snippet('header') ?>
<?php 
$image = $page->parent()->images()->findBy('name', $page->slug());
dump($image);
?>
<?php snippet('footer') ?>