#55828 closed enhancement (fixed)
Add filter in `wp_read_audio_metadata` function
Reported by: | luigipulcini | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch commit needs-dev-note |
Focuses: | Cc: |
Description
At the moment, the function wp_read_audio_metadata
is returning the $metadata
extracted from an uploaded audio file without applying any filter to it. In addition to the limitations that this poses (e.g. third-party plugins may want/need to attach additional properties to the $metadata
array by pulling them from the $data
array), the missing filter also seems to be in contrast and inconsistent with the corresponding wp_read_image_metadata
and wp_read_video_metadata
functions, which both filter the file metadata array before returning it (here for images and here for videos).
This could easily be fixed by simply replacing line 3700:
return $metadata;
with
return apply_filters( 'wp_read_audio_metadata', $metadata, $file, $data );
There are so many properties stored in the ID3 tag that get_id3()
is capable of extracting from the file but WordPress simply leaves behind that this filter is very much needed and is perfectly consistent with what WordPress already has for images and videos, including its hook name.
Change History (10)
This ticket was mentioned in PR #2747 on WordPress/wordpress-develop by LuigiPulcini.
2 years ago
#1
#4
@
2 years ago
Hi there!
As we have $file_format
for the wp_read_video_metadata
filter do we need it for audio filter?
Can you please update @since 6.0.1
tag to @since 6.1.0
?
#5
in reply to:
↑ 3
@
2 years ago
Good point about the $file_format
parameter, @mukesh27.
I initially left it out just because it is always possible to access it from both the $metadata
and the $data
parameters. But I agree with you that this will improve the consistency between the two audio and video filters.
I will also update the @since
tag.
#6
@
2 years ago
- Keywords commit needs-dev-note added
- Owner set to audrasjb
- Status changed from new to accepted
- Version trunk deleted
Thanks for spotting this and for the PR,
Self assigning for commit
consideration.
2 years ago
#8
Committed in https://core.trac.wordpress.org/changeset/53764
At the moment, the function wp_read_audio_metadata is returning the
$metadata
extracted from an uploaded audio file without applying any filter to it. In addition to the limitations that this poses (e.g. third-party plugins may want/need to attach additional properties to the$metadata
array by pulling them from the$data
array), the missing filter also seems to be in contrast and inconsistent with the correspondingwp_read_image_metadata
andwp_read_video_metadata
functions, which both filter the file$metadata
array before returning it (here for images and here for videos).This could easily be fixed by simply replacing line 3700:
with
There are so many properties stored in the ID3 tag that the
getID3()
class is already extracting from the uploaded file but WordPress simply leaves behind that this filter is very much needed and is perfectly consistent with what WordPress already has for images and videos, including its hook name.Trac ticket: https://core.trac.wordpress.org/ticket/55828