Fetching images from a subpage's structure

Hello all,

I am kind of new to Kirby & PHP & Development in general.
I hope I’ll manage to formulate my question clearly as I got a little stuck here.

I am trying to call images from a structure field.
The structure field is on the children’s pages of my home.

My code looks like that:

  $slides = $page->gallery()->toStructure();

<div class="swiper__container">
   <div class="swiper__wrapper">
      <?php foreach ($slides as $slide):
          $src     = $slide->image()->toFiles();
         <div class="swiper__slide">
            <img src="<?= $src ?>">
       <?php endforeach ?>

Which results in seeing broken image icons on my page and these having a wrong path.
Opening the image in a new tab also shows a strange double “home”:


I tried troubleshooting via some other similar problems I have found in other – already solved – topics with no success! I am quite aware must be a problem of “addressing” the right path in my PHP but I am somehow still failing!

Thank you for your support!

What does the blue print for the structure field look like? Are literally just using it for the images? If thats the case, and a files field would be better here, as its designed to store a set of image.

Your source doesnt seem have a URL which i think should make it work:

<?php if($image = $slide->image()->toFile()): ?>
  <img src="<?= $image->url() ?>" alt="">
<?php endif ?>

Notice that i change toFile() to the singular.

Thank you!
It seems to work as I change the field from structure to file and fetch the images from there!