diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php
index d0fdbe013..59204e656 100644
--- a/e107_handlers/e_parse_class.php
+++ b/e107_handlers/e_parse_class.php
@@ -4931,7 +4931,27 @@ class e_parse
$file = $this->replaceConstants($file, 'abs');
- $mime = varset($parm['mime'], 'audio/mpeg');
+ $ext = pathinfo($file, PATHINFO_EXTENSION);
+
+ switch (strtolower($ext))
+ {
+
+ case 'wav':
+ $mime = 'audio/wav';
+ break;
+ case 'ogg':
+ $mime = 'audio/ogg';
+ break;
+ case 'mp3':
+ default:
+ $mime = 'audio/mpeg';
+ break;
+ }
+
+ if(!empty($parm['mime']))
+ {
+ $mime = $parm['mime'];
+ }
$autoplay = !empty($parm['autoplay']) ? 'autoplay ' : '';
$controls = !empty($parm['controls']) ? 'controls' : '';
diff --git a/e107_tests/tests/unit/e_parseTest.php b/e107_tests/tests/unit/e_parseTest.php
index dbe90fdb8..1def8c9cf 100644
--- a/e107_tests/tests/unit/e_parseTest.php
+++ b/e107_tests/tests/unit/e_parseTest.php
@@ -2659,7 +2659,24 @@ Your browser does not support the audio tag.
';
$result = $this->tp->toAudio('{e_MEDIA}myfile.mp3');
- $this->assertEquals($expected, $result);
+ self::assertEquals($expected, $result);
+
+ $expected = '';
+
+ $result = $this->tp->toAudio('{e_MEDIA}myfile.wav');
+ self::assertEquals($expected, $result);
+
+ // Override mime.
+ $expected = '';
+
+ $result = $this->tp->toAudio('{e_MEDIA}myfile.php', ['mime' => 'audio/wav']);
+ self::assertEquals($expected, $result);
}