Image URLs without hash


is it possible to change the file urls on an existing Kirby website?

Actually it should look like this:
mysite. de/media/pages/PAGENAME/FILENAME

But it would be best like this:
mysite. de/media/FILENAME

I tested a solution here from the forum.

<?php Kirby::plugin('yourname/old-file-urls', [ 'components' => [ 'file::url' => function (Kirby $kirby, $file) { return $kirby->url() . '/content/' . $file->parent()->diruri() . '/' . $file->filename(); }, ] ]);

But when I use the plugin, no files are displayed at all.
The URL to images or PDF files is as expected but a 404 error occurs.

Thank you for your help

The plugin’s purpose is to serve files directly from the content folder, which only works for original files but not if you are using thumbs.

You cannot change the path inside the media folder, at least not without creating new file models (and your suggested patterns wouldn’t work if for example, different pages had different files with the same filename).

Thanks for the quick feedback.

So there no way to generate file urls like this:
mysite. de/media/pages/PAGENAME/FILENAME

No, in fact, the media route wouldn’t find the image with such a path.

As I said, you can serve images directly from content instead of the media folder but you cannot influence the media path.

Is there another way to bypass file paths like
/media/pages/home/1d26457bb7-1646054193/filename ?

May I ask what you have in mind for not using the hashed URLs?