1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-16 12:18:39 +01:00

Fixes #5390 Incorrect mime-type when using toAudio() with .wav files.

This commit is contained in:
camer0n 2025-01-14 15:45:38 -08:00
parent b51833b794
commit e8f5e804b2
2 changed files with 39 additions and 2 deletions

View File

@ -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' : '';

View File

@ -2659,7 +2659,24 @@ Your browser does not support the audio tag.
</audio>';
$result = $this->tp->toAudio('{e_MEDIA}myfile.mp3');
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);
$expected = '<audio controls style="max-width:100%" >
<source src="/e107_media/000000test/myfile.wav" type="audio/wav">
Your browser does not support the audio tag.
</audio>';
$result = $this->tp->toAudio('{e_MEDIA}myfile.wav');
self::assertEquals($expected, $result);
// Override mime.
$expected = '<audio controls style="max-width:100%" >
<source src="/e107_media/000000test/myfile.php" type="audio/wav">
Your browser does not support the audio tag.
</audio>';
$result = $this->tp->toAudio('{e_MEDIA}myfile.php', ['mime' => 'audio/wav']);
self::assertEquals($expected, $result);
}