解析ID3v2,ID3v1和getID3注释以提取可用数据

原型

wp_add_id3_tag_data( array $metadata, array $data )

参数

$metadata (array) (Required) 包含数据的现有数组

$data (array) (Required) ID3标签提供的数据

源文件

路径:wp-admin/includes/media.php

<?php
...
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] = wp_kses_post( reset( $list ) );
					// Fix bug in byte stream analysis.
					if ( 'terms_of_use' === $key && 0 === strpos( $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']
			);
		}
	}
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/