From ce00971ca1a8a676caab2949a87292d5a5eb3b5a Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Sat, 23 Jul 2022 08:11:51 +0000 Subject: [PATCH] Media: Allow filtering audio file metadata in `wp_read_audio_metadata()`. This changeset introduces the `wp_read_audio_metadata` hook which allows to filter metadata extracted from an uploaded audio file. This brings consistency with corresponding filters available for image and video file types: - `wp_read_image_metadata` added in [6313] / #5162. - `wp_read_video_metadata` added in [41746] / #35218. Props luigipulcini, SergeyBiryukov, mukesh27. Fixes #55828. git-svn-id: https://develop.svn.wordpress.org/trunk@53764 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 6a641658b5..3d91d5f62d 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -3697,7 +3697,22 @@ function wp_read_audio_metadata( $file ) { wp_add_id3_tag_data( $metadata, $data ); - return $metadata; + $file_format = isset( $metadata['fileformat'] ) ? $metadata['fileformat'] : null; + + /** + * Filters the array of metadata retrieved from an audio file. + * + * In core, usually this selection is what is stored. + * More complete data can be parsed from the `$data` parameter. + * + * @since 6.1.0 + * + * @param array $metadata Filtered Audio metadata. + * @param string $file Path to audio file. + * @param string $file_format File format of audio, as analyzed by getID3. + * @param array $data Raw metadata from getID3. + */ + return apply_filters( 'wp_read_audio_metadata', $metadata, $file, $file_format, $data ); } /**