Is there a way to regenerate the entire 'media' folder?

I am using Kirby as a headless CMS, providing data to a PWA as JSON via custom endpoints setup as routes. I’m processing my routes with snippets and these generate the data structures required using normal Kirby methods.

I have migrated Kirby to a new server, and the URLs provided by the methods such as $image->resize(1920, 1080)->url(); are referring to files in the /media directory which aren’t present on the new server and therefore aren’t showing up.

Is there a way to get Kirby to either [a] regenerate all these files programatically or [b] somehow reset the relationship that causes Kirby to think they are there in the first place?

Or do I have to upload all the files to the new server (there are a hella lot of 'em)? :frowning:

My files/images do not have a blueprint assigned but would something like the update-metadata.php work for this?

In a standard Kirby setup, the media folder is automatically created and the files in there on the fly when a file URL is called. The same should actually happen when the methods are called inside a route.

Is the media folder created at all once it is removed?

@pixelijn Yes, the media folder is there, and some new files are being created (I’m not 100% sure what the pattern is of when it does and doesn’t work as expected), but it seems Kirby believes items in the media folder that were generated on the previous server are still present. Is there a cache or index I can clear to force it to regenerate those? The situation I’m experiencing is as if I accidentally copied over an index of the previous media folder jobs but not the files in the media folder.

With Kirby v2, the item not being present in the cache folder was sufficient?

Do you think something like cleaning the cache in this manner would do it?

It’s very weird that it sometimes works, and sometimes fails…

Is there any pattern to be recognized when it fails? Permissions, file size, error logs, … ?

As @pixelijn mentioned; files in media are copied/generated when they are requested via URL. AFAIK the only way to create them automatically is to create a script somewhere that visits all pages of the website. And, to make matters more complicated, if you use e.g. srcset etc you’ld have to do it for each “breakpoint”…

janitor plugin has a script visit/render all pages and another to generate thumbs based on job files in media folder. you could trigger one or both from the CLI.