The Media folder and an issue with .mp3 files

Hi,

My understanding in generell to the Media folder is to store resized images by a function for example, to hold the original one in the corresponding content folder. I guess that is not everthing, but this is my actual view.

In case of .mp3 files, Kirby has the same approach to store a copy of the .mp3 file in the Media folder. For me it makes no sense, because I have no changes to the audio file and more I have to spent double space on my webserver for every single .mp3 file.

What is the benefit in this standard approach to create a copy of an audio file into the Media folder and how can I disable this approch only for .mp3 files in case of no benefit?

Thank you

Hi,

this article should help you

Cheers

David

1 Like

Part 1: Exploring the Starterkit | Kirby CMS

1 Like

Thank you both!!!

For you all the best for 2025.

Sorry, I have to reopen this issue.

I considered the plugin based from the article, to exclude only video files from the media-folder. My change was only to substitude the parameter video to audio with:

<?php

// import App class
use Kirby\Cms\App as Kirby;

Kirby::plugin('cookbook/file-component', [
  'components' => [
    'file::url' => function (Kirby $kirby, $file) {
        // serve videos from content folder
        if ($file->type() === 'audio') {
            return $kirby->url() . '/content/' . $file->parent()->diruri() . '/' . $file->filename();
        // while all other files are served from the media folder
        } else {
            return $file->mediaUrl();
        }

    },
  ]
]);

Together with the necessary step to comment out a line in the .htaccess file.

# block all files in the content folder from being accessed directly
# RewriteRule ^content/(.*) index.php [L]

Everthing is fine so far, the URL to my mp3-file is directed to the content folder and not more to the media folder, but nevertheless Kirby creates a copy of the mp3-file into the media folder!

Why?