newStructure from kirbyTag in plugin

In Kirby3 I had a custom KirbyTag for a slider that worked just fine.
I upgraded to Kirby4 and now I get an error “Call to a member function image() on array” for the file slideshow.php. Any idea, why it’s not working?

In my textarea I have a tag like this:
(slideshow: image1.jpg|image2.jpg texts: Text 1|Text 2)

This is my plugin site/plugins/tag/index.php

Kirby::plugin('my/slideshow', [
    'tags' => [
        'slideshow' => [
            'attr' => array(
                'texts',
            ),
            'html' => function($tag) {
                $filenames = explode('|', $tag->attr('slideshow'));
                $texts = explode('|', ''.$tag->attr('texts'));

                $slides = [      ];
                foreach ($filenames as $index => $filename) {
                $slides[] = [
                    'image' => $filename, 
                    'text'  => isset($texts[$index]) ? $texts[$index] : '',
                        ];
                }
                $snippet = snippet('slideshow', array(
                    'slides' => new Structure($slides, [$tag->parent()]),
                    'sizes' => 'content',
                ), true);
                return $snippet;
            }
        ]
    ]
]);

And in my snippet site/snippet/slideshow.php

...

<?php foreach ($slides as $slide) : ?>
      <div class="slide-inner">
            <img scr="<?= $slide->image()->toFile()->url() ?>" class="<?= $sizes ?>">
            <p><?= $slide->text() ?></p>
      </div>
<?php endforeach ?>
...