Get .mp3 file from assets folder

Is there a way to get an .mp3 file from a plugin’s assets folder? No matter what I try it doesn’t seem to find the asset. It does currently work with images css-files and javascript-files, but not with sound-files?

I use the format media/my/plugin/path/inside/assets/folder.ext.

Anything I am missing here?

There is no route for mp3 files, this is the route pattern:

'pattern' => $media . '/plugins/(:any)/(:any)/(:all).(css|gif|js|jpg|png|svg|webp|woff2|woff)',


What is your use case for having sound files in your plugin folder?

I figured, thats sad.

For sounds on a webpage? I use a plugin to add kirby tags, in the tag I use sound que’s for certain actions. Those sounds are bound to that specific component, and in a specific way.

I don’t think it enhances the usability if I ask a plugin user to set up their web content in a specific way in order for the plugin to work.

So is there a way to solve this issue? Maybe using routes, although I haven’t found a way to return a plain file (especially non-text files).

If you add such a route in your plugin, this will at least resolve the url:

'routes' => [
        'pattern' => 'media/plugins/(:any)/(:any)/(:all).(mp3)',
        'env'     => 'media',
        'action'  => function (string $provider, string $pluginName, string $filename, string $extension) {
            return PluginAssets::resolve($provider . '/' . $pluginName, $filename . '.' . $extension);

That seems to work. I am curious though, what is the property env about? is it needed because the return type is a media?

I have no idea for what purpose this is used, I just copied the original route and modified the pattern.