Images with templates are not deleted from a project

Hey,
This is not really an issue but a behaviour I’d like to understand.
I’m making a website where the user can upload images.
Here is my blueprint :

    medias:
        uploads: videoimg
        width: 2/3
        label: Images
        type: files
        layout: cards
        size: medium
        text: "{{file.caption}}"
        info: "🎥 : {{file.videoLink}}"
        image:
          back: "black"
          icon: 🎥

So when the user upload a file to that part of the blueprint, it get the template videoimg and is now displayed in the medias list. So the project.txt is like that:

Hero: - file://jZZ3HFwVVvrjA2KQ

----

Medias:

- file://B2JRYCRjG9utrW17
- file://jZZ3HFwVVvrjA2KQ

There is an Hero field because the user can upload another image that will be used as an Hero for the project.
I later fetch my wanted files in my project.php like that :
<?php foreach ($page->images()->filterBy('template', 'videoimg')->sortBy('sort') as $image) : ?> and so on.

Now, when I remove the image for the medias section, obviously the image is not removed from the project, but from that list. So it’s kept in the project files, which is not really wanted.
So I’m wondering if it’s really the good way to do if I want my user to upload different type of files in different sections (hero and medias here)

Thanks.

Maybe you want 2 files sections instead of 2 files fields ? Especially if you then search for them by template, and not via the $page->medias()->toFiles() field method.

Yep, maybe,
actually, I’ve tried a few things but I don’t know why it’s not working, here is my blueprint :

  files:
    label: Files
    icon: file-image
    sections:
      info-img:
        theme: normal
        label: About this project
        type: info
        text: Contains **{{ page.files.count }}** images. For a total of **{{ page.files.niceSize }}**
    sections:
      hero:
        width: 1/3
        label: Zoomed image
        help: (Should be in portrait mode)
        type: files
        layout: cards
        size: huge
        text: "{{file.name}} - {{file.orientation}}"
        multiple: false
        search: false
        image:
          cover: true
          ratio: 2/3
    sections:
      medias:
        uploads: videoimg
        width: 2/3
        label: Images
        type: files
        layout: cards
        size: medium
        text: "{{file.caption}}"
        info: "🎥 : {{file.videoLink}}"
        image:
          back: "black"
          icon: 🎥

Is having multiple sections like that is correct?

That definitely doesn’t look right.
Can you post the entire blueprint?

Assuming that files is a tab, remove the excess sections keys and add a template property to each (and remove uploads)

files:
    label: Files
    icon: file-image
    sections:
      info-img:
        theme: normal
        label: About this project
        type: info
        text: Contains **{{ page.files.count }}** images. For a total of **{{ page.files.niceSize }}**
      hero:
        template: hero
        width: 1/3
        label: Zoomed image
        help: (Should be in portrait mode)
        type: files
        layout: cards
        size: huge
        text: "{{file.name}} - {{file.orientation}}"
        multiple: false
        search: false
        image:
          cover: true
          ratio: 2/3
      medias:
        template: videoimg
        width: 2/3
        label: Images
        type: files
        layout: cards
        size: medium
        text: "{{file.caption}}"
        info: "🎥 : {{file.videoLink}}"
        image:
          back: "black"
          icon: 🎥

Yep, alright, this is working now.
I’m gonna read the doc about uploads and template to understand more precisely the difference.