In WordPress 3.6, using the new [audio] shortcode, I can add a player for an .mp3 file like this:

[audio src="http://example.com/audio_files/test.mp3"]

However, if the .mp3 file has capital letters in the extension, it doesn't work:

[audio src="http://example.com/audio_files/test_capital.MP3"]

If I specify the format in the shortcode, it still fails, although in a different way:

[audio mp3="http://example.com/audio_files/test_capital.MP3"]

Looking at function wp_audio_shortcode in "wp-includes/media.php", I can see where this is happening.

Is this intentional behavior for WordPress 3.6? Are there any workarounds (other than renaming the file)? Should I file a bug report?


This bug has been fixed in the core for WordPress 3.7.

  • How are these files uploaded? I've never encountered a situation where WordPress didn't convert the extension to lowercase on upload, making this a non-issue. – Milo Aug 22 '13 at 20:44
  • @Milo, interesting point. These would be files uploaded via FTP, or even files on a separate, non-WordPress server. I'll edit the question so it doesn't look like they were uploaded via WordPress. – Ben Miller Aug 22 '13 at 20:46
  • 1
    have a look in source at the file extension and mimetype arrays used by the shortcode handler, both should have filters to let you modify them, you may be able to add capitalized versions. – Milo Aug 22 '13 at 20:51
  • 1
    seems like a bug to me - filed a report to the WordPress Core trac with a patch for that issue. – Mario Peshev Aug 25 '13 at 15:37
  • 1
    Thanks, Mario! For anyone who is curious, here is the ticket. – Ben Miller Aug 26 '13 at 4:41

No, apparently not. Until this behavior is changed in version 3.7 you can add this filter to your theme's functions.php file to include additional extensions.

Edited: I've updated the filter with better code suggested in the comments.

Lower case and uppercase extensions

function my_custom_audio_extensions( $exts ) {
    //merge array of upper case extensions with default array
    return array_merge( $exts, array_map('strtoupper', $exts) );
add_filter( 'wp_audio_extensions', 'my_custom_audio_extensions' );

Lower case, upper case, and first letter capitalized extensions

function my_custom_audio_extensions( $exts ) {
    //merge array of lower case defaults, uppercase and first letter capitalized
    return array_merge( $exts, array_map('strtoupper', $exts), array_map('ucfirst', $exts));
add_filter( 'wp_audio_extensions', 'my_custom_audio_extensions' );
  • 2
    +1. Alternative way is function my_custom_audio_extensions( $exts ) { return array_merge( $exts, array_map('strtoupper', $exts) ); } is more future proof :) – gmazzap Aug 28 '13 at 0:02
  • Yes, Brilliant! We don't need to add extensions for additional format types, we just need to allow capital extensions. I'll revise my answer. – epilektric Aug 28 '13 at 0:13
  • Thanks. This will allow extensions in all caps to work (.MP3), but if your extension is mixed case (.Mp3), it still won't work. And if you want to make the same change to video files, you'll need another filter. The fix in WordPress 3.7 affects both the audio and video shortcodes and allows mixed-case extensions. But this is a great workaround solution until then. – Ben Miller Aug 28 '13 at 3:44
  • @BenMiller Yes, this solution is all caps only. My previous version was a little less dummy-proof but you could specify mixed case extensions if you wanted. This was the code array_push( $exts, 'MP3', 'OGG', 'WMA', 'M4A', 'WAV' ); return $exts; – epilektric Aug 28 '13 at 4:21
  • 1
    @BenMiller if you want you can append also extension with only the 1st capital letter: return array_merge( $exts, array_map('strtoupper', $exts), array_map('ucfirst', $exts)) – gmazzap Aug 29 '13 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.