From 32cc05a7c03deefafaedc0959824a1f78f5a8e75 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Sat, 23 Jul 2022 08:13:11 +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. Built from https://develop.svn.wordpress.org/trunk@53764 git-svn-id: http://core.svn.wordpress.org/trunk@53323 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 17 ++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 6a641658b5..3d91d5f62d 100644 --- a/wp-admin/includes/media.php +++ b/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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 64d5314edd..84bf13e032 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53763'; +$wp_version = '6.1-alpha-53764'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.