Virtual page with custom block method - Problem

Hello,

I have a custom block on which I want to apply a custom block method.
This method should allow me to create virtual pages from the block images.

Things seem to work pretty well : each image is associated to a Page object.
My problem : the url of the virtual page takes me to an error template and not the template I gave it in the Page::factory.

What I’m missing? v_V


Kirby::plugin('my/block-methods', [
    'blockMethods' => [
        'recupPagesVirtuelles' => function () {

[...I get a $images array with my images ...]

 foreach ($images as $image) {
            $tab[] = [
                'slug'     => $image->name(),
                'template' => 'gallery-image',
                'model'    => 'gallery-image',
                'dirname' => $this->dirname(),
                    ];
                }
            return Pages::factory($tab, $this->parent());
            }
    ]
]);

The problem is that you are creating these virtual pages on the fly, without actually registering them as virtual pages. This won’t work like this. Each parent page that uses such a block would need a model that defines those images as children.