forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Media: add
x-wav
mime type for wav files in Firefox (WordPress#66850)
Adding x-wav support because Firefox uses that identifier Check if wav does not exist in case some plugins or themes have already filtered it out. Co-authored-by: ramonjd <[email protected]> Co-authored-by: Imran92 <[email protected]>
- Loading branch information
1 parent
2a3e379
commit 074dc52
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/7265 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/66850 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* Adds the x-wav mime type to the list of mime types. | ||
* This is necessary for Firefox as it uses the identifier for uploaded .wav files. | ||
* Core backport should add the following to the default mime_types filters in | ||
* `wp_get_mime_types()` in wp-includes/functions.php: | ||
* | ||
* `'wav|x-wav' => 'audio/wav'` | ||
* | ||
* @since 6.8.0 | ||
* | ||
* @param string[] $mime_types Mime types. | ||
* @return string[] Mime types keyed by the file extension regex corresponding to those types. | ||
*/ | ||
function gutenberg_get_mime_types_6_8( $mime_types ) { | ||
/* | ||
* Only add support if there is existing support for 'wav'. | ||
* Some plugins may have deliberately disabled it. | ||
*/ | ||
if ( ! $mime_types['wav'] && ! isset( $mime_types['wav|x-wav'] ) ) { | ||
return $mime_types; | ||
} | ||
/* | ||
* Also, given that other themes or plugins may have already | ||
* tried to add x-wav type support, only | ||
* add the mime type if it doesn't already exist | ||
* to avoid overriding any customizations. | ||
*/ | ||
if ( ! isset( $mime_types['x-wav'] ) && ! isset( $mime_types['wav|x-wav'] ) ) { | ||
$mime_types['x-wav'] = 'audio/wav'; | ||
} | ||
return $mime_types; | ||
} | ||
add_filter( 'mime_types', 'gutenberg_get_mime_types_6_8', 99 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters