How to group files (images) on a kirby page

I have a blueprint with has a main cover image and then several separate galleries. I thought with giving each collection a different template it could work. Now the following happend: A user uploaded an image to galleryKitchen and then “selected” the same pic for the mainImage. So the mainImage did no longer has the template “cover” and I got a NPE :frowning: Are there better ways to group files on page?

title: Projekt
sections:
  info:
    type: fields
    fields:
      mainImage:
        label: Hauptbild
        type: files
        size: tiny
        multiple: false
        uploads:
          template: cover
        image:
          ratio: 1/1
          cover: true
        width: 1/3
      galleryKitchen:
          headline: Küchen
          width: 1/1
          type: files
          layout: cards
          template: gallery-kitchen
          image:
            ratio: 16/9
            cover: true
        galleryBathroom:
          headline: Badezimmer
          width: 1/1
          type: files
          layout: cards
          template: gallery-bathroom
          image:
            ratio: 16/9
            cover: true
        ....

Since you are using fields, applying different templates to those files is not really necessary, because you get the files from what you selected in the field, e.g.

$kitchenGalleryImages = $page->galleryKitchen()->toFiles();

$bathroomGalleryImages = $page->galleryBathroom()->toFiles();