Title: Adding MP3 by using hooks
Last modified: February 27, 2024

---

# Adding MP3 by using hooks

 *  Resolved [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/)
 * I want to add external mp3 files to the media library by using hooks. Now i am
   not sure, where to add the code.
 * add_filter( ’eml_supported_mime_types’, function( $list ) {
    $list[‘audio/mp3’]
   = array( ‘label’ => ‘MP3 Audio’, ‘ext’ => ‘mp3’ ); return $list} );
 * Does the code belong in the functions.php of the theme?

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17457350)
 * If you have a child theme, you can put it in its `functions.php`. If you don’t
   have a child theme, use the [code snippet plugin](https://wordpress.org/plugins/code-snippets/)
   or something similar.
 * Pay attention to the exact spelling of the code. Here in the forum, the inverted
   commas are misspelled in your post. I don’t know if this is due to your source
   for the code or the lack of formatting as a code block in your post. The code
   should actually look like this:
 *     ```wp-block-code
       add_filter( 'eml_supported_mime_types', function( $list ) {
        $list['audio/mp3'] = array(
         'label' => 'MP3 Audio',
         'ext' => 'mp3'
        );
        return $list
       } );
       ```
   
 *  Thread Starter [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17457517)
 * Thanks for the quick reply. I have installed the code snippet plugin. Now I get
   a syntax error when I enter the code.
 * Parse Error : syntax error , unexpected ‘}’, expecting ‘;’ on line 7
 *  Plugin Author [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17457538)
 * Ah, yes, there is a “;” missing. Corrected:
 *     ```wp-block-code
       add_filter( 'eml_supported_mime_types', function( $list ) {
           $list['audio/mp3'] = array(
               'label' => 'MP3 Audio',
               'ext' => 'mp3'
           );
           return $list;
       } );
       ```
   
 *  Thread Starter [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17457600)
 * Now the snippet plugin is working. If I now want to load an mp3 file from a Dropbox
   into the media library, the following error message appears:
 * The specified URL [https://www.dropbox.com/………&#8230](https://www.dropbox.com/………&#8230);.
   responds with an invalid content-type text/html; charset=utf-8.
 *  Plugin Author [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17457610)
 * This obviously doesn’t work because the URL you entered is an HTML page and not
   an MP3 file. To do this, dropbox.com would have to provide you with such a direct
   URL. According to their documentation, this is possible with an additional parameter
   in the URL: [https://help.dropbox.com/de-de/share/force-download](https://help.dropbox.com/de-de/share/force-download)
 *  Thread Starter [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17464452)
 * Unfortunately I haven’t made any progress. In the Dropbox, I used “dl=1” and “
   raw=1” as query parameters in the link. In both cases I get the error message:
   _The specified URL [https://www.dropbox.com/*&raw=1](https://www.dropbox.com/*&raw=1)
   responds with http-status 302._**_ _**
 * I have tried another puplic folder in another cloud and I get the error:**_ _**
   _The specified URL [https://filedn.eu/.mp3](https://filedn.eu/.mp3) responds 
   with http-status 404_.
   What am I doing wrong?
 *  Plugin Author [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17465154)
 * The URLs you are using apparently do not return any importable files. A http-
   status 404 means the file does not exist.
 * You can test it e.g. with `https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/
   pdf/dummy.pdf` – this must work as this importable file is directly accessible.
 * For files that you want to import this way, you need exactly such URLs. They 
   must refer directly to the file.
 *  Thread Starter [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17465553)
 * Now I have found the solution. The content type is not audio/mp3 but audio/mpeg.
 * add_filter( ’eml_supported_mime_types’, function( $list ) {
   $list[‘audio/mpeg’]
   = array(‘label’ => ‘MP3 Audio’,‘ext’ => ‘mp3’);return $list;} );
 *  Plugin Author [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17465612)
 * Great if you have found a solution. For me, this points to a faulty content type
   on the part of the URLs you are using. But it is of course also a solution.
 * You are welcome to set the topic to solved once it has been clarified for you.
 *  Thread Starter [dripstone](https://wordpress.org/support/users/dripstone/)
 * (@dripstone)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17465626)
 * The problem with the URL was spaces in the file name. Now everything works great.
   Thank you for your patience.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Adding MP3 by using hooks’ is closed to new replies.

 * ![](https://ps.w.org/external-files-in-media-library/assets/icon-256x256.jpg?
   rev=3477016)
 * [External files in Media Library](https://wordpress.org/plugins/external-files-in-media-library/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/external-files-in-media-library/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/external-files-in-media-library/)
 * [Active Topics](https://wordpress.org/support/plugin/external-files-in-media-library/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/external-files-in-media-library/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/external-files-in-media-library/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [dripstone](https://wordpress.org/support/users/dripstone/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/adding-mp3-by-using-hooks/#post-17465626)
 * Status: resolved