wp_add_id3_tag_data( array $metadata, array $data )
- Since
- 3.6.0
- Source
wp-admin/includes/media.php:3554
Parses ID3v2, ID3v1, and getID3 comments to extract usable data.
Parameters
$metadataarray- An existing array with data.
$dataarray- Data supplied by ID3 tags.
Uses · 3
- wp_kses_post_deep()Navigates through an array, object, or scalar, and sanitizes content for allowed HTML tags for post content.
- wp_kses_post()Sanitizes content for allowed HTML tags for post content.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
Used by · 2
- wp_read_audio_metadata()Retrieves metadata from an audio file's ID3 tags.
- wp_read_video_metadata()Retrieves metadata from a video file's ID3 tags.
Source
function wp_add_id3_tag_data( &$metadata, $data ) { foreach ( array( 'id3v2', 'id3v1' ) as $version ) { if ( ! empty( $data[ $version ]['comments'] ) ) { foreach ( $data[ $version ]['comments'] as $key => $list ) { if ( 'length' !== $key && ! empty( $list ) ) { $metadata[ $key ] = is_array( $list ) ? wp_kses_post_deep( reset( $list ) ) : wp_kses_post( $list ); // Fix bug in byte stream analysis. if ( 'terms_of_use' === $key && str_starts_with( $metadata[ $key ], 'yright notice.' ) ) { $metadata[ $key ] = 'Cop' . $metadata[ $key ]; } } } break; } } if ( ! empty( $data['id3v2']['APIC'] ) ) { $image = reset( $data['id3v2']['APIC'] ); if ( ! empty( $image['data'] ) ) { $metadata['image'] = array( 'data' => $image['data'], 'mime' => $image['image_mime'], 'width' => $image['image_width'], 'height' => $image['image_height'], ); } } elseif ( ! empty( $data['comments']['picture'] ) ) { $image = reset( $data['comments']['picture'] ); if ( ! empty( $image['data'] ) ) { $metadata['image'] = array( 'data' => $image['data'], 'mime' => $image['image_mime'], ); } }}History
Introduced in 3.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.