Allow to delete media files

Could someone guide me on what would be the best way to give a client access to permanently delete unused media files from the site?

I know one way would be to give access to the /media folder via FTP to make this possible – but is there any more practical way to do this within the panel, for example?

Thanks in advance

When a file is deleted via the Panel, the file is also removed from the media folder.

What exactly do you want the user to be able to remove?

Sorry for not being clear enough.
I am thinking on a way to display an assets section or similar, where the client can delete unused images; instead of doing it through the subpages.

You mean a global section with all images from the site? You could either set up a custom files section in site.yml which allows querying the whole site, or you create a custom Panel area for the purpose.

The problem with such a global section is that it becomes more difficult for a user to know if a file is used anywhere (unless you provide that information, which is not always easy, because images can be used in many places).

Yes that is what I want. Either of these solutions would work – having a dedicated section in the panel would be even better. Regarding the difficulty for the user to know if a file is used somewhere, that is not a problem.

Do you have any guidelines on how I could achieve such thing?

For a separate Panel area, this recipe should help you get started: Advanced Panel area | Kirby CMS

A separate files section somewhere with all files of the page (and using my filedisplay plugin which currently doesn’t work :see_no_evil:) would be a lot easier to implement, though.

If this is a new project, you might consider setting up a central media page right from the beginning, and query all files sitewide from there.

Hey!
I managed to create a plugin that retrieves all the files uploaded to the site and allows to remove them from the /content/ folder. This solves the issue partially, as all the files are generated also to the media folder. Is there a way I can solve that? Since each file is wrapped into a folder and generates several versions for the size, is difficult to target each specific file from the media folder.

Happy to share more details on the code.

Thanks @anta for your question. I have been missing the same functionality here. Having a easier and more straightforward wait to deal with old unused files in the content folder out form the box would be pretty helpful.

Please, would you share the process or code of the plugin you created?

Thanks a lot