Title: wp_add_id3_tag_data
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_add_id3_tag_data( array $metadata, array $data )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#wp--skip-link--target)

Parses ID3v2, ID3v1, and getID3 comments to extract usable data.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#parameters)󠁿

 `$metadata`arrayrequired

An existing array with data.

`$data`arrayrequired

Data supplied by ID3 tags.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#source)󠁿

    ```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 ] = 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'],
    			);
    		}
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/media.php#L3554)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/media.php#L3554-L3589)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_kses_post_deep()](https://developer.wordpress.org/reference/functions/wp_kses_post_deep/)`wp-includes/kses.php` |

Navigates through an array, object, or scalar, and sanitizes content for allowed HTML tags for post content.

  | 
| [wp_kses_post()](https://developer.wordpress.org/reference/functions/wp_kses_post/)`wp-includes/kses.php` |

Sanitizes content for allowed HTML tags for post content.

  |

| Used by | Description | 
| [wp_read_video_metadata()](https://developer.wordpress.org/reference/functions/wp_read_video_metadata/)`wp-admin/includes/media.php` |

Retrieves metadata from a video file’s ID3 tags.

  | 
| [wp_read_audio_metadata()](https://developer.wordpress.org/reference/functions/wp_read_audio_metadata/)`wp-admin/includes/media.php` |

Retrieves metadata from an audio file’s ID3 tags.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.6.0](https://developer.wordpress.org/reference/since/3.6.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/?output_format=md#comment-content-1482)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_add_id3_tag_data/#comment-1482)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_add_id3_tag_data%2F%23comment-1482)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_add_id3_tag_data%2F%23comment-1482)
 4. **Example**
 5.     ```php
        $metadata = array();
        if ( ! class_exists( 'getID3' ) ) {
        	require( ABSPATH . WPINC . '/ID3/getid3.php' );
        }
        $id3 = new getID3();
        $data = $id3->analyze( $file );
        wp_add_id3_tag_data( $metadata, $data );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_add_id3_tag_data%2F%3Freplytocom%3D1482%23feedback-editor-1482)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_add_id3_tag_data%2F)
before being able to contribute a note or feedback.