Clear page media cache

We are looking for a way to clear the media cache (generated thumbs) of the current page. Ideally by placing a button in the panel.

Has anyone done something like this?

Check out the Janitor plugin: https://github.com/bnomei/kirby3-janitor

It allows you to define custom actions.

2 Likes

Do we have core functions in Kirby to clear the media cache or is this something weβ€˜d have to code ourselves?

I’m not aware of a method that does that but you can just remove the complete folder as that is recreated anyway?

Edit:

You can unpublish files via the $file->unpublish() method, which removes all published versions of a file.

This would allow you to remove files selectively (i.e. just the files in a given page), rather than clearing the complete folder.

1 Like

Ah, thatβ€˜s what I was looking for – cool! Do I have to publish the files again to get new job files or will Kirby do this on next request?

The files are recreated when they are requested again.

1 Like

Perfect, thanks :+1: