wp_add_id3_tag_data

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

Description

wp_add_id3_tag_data( (array) &$metadata, (array) $data ); 

Parameters (2)

0. $metadata (array) => &$metadata
An existing array with data
1. $data (array)
Data supplied by ID3 tags

Usage

  1. if ( !function_exists( 'wp_add_id3_tag_data' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/media.php'; 
  3.  
  4. // An existing array with data 
  5. $metadata = array(); 
  6.  
  7. // Data supplied by ID3 tags 
  8. $data = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_add_id3_tag_data($metadata, $data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/media.php  
  1. function wp_add_id3_tag_data( &$metadata, $data ) { 
  2. foreach ( array( 'id3v2', 'id3v1' ) as $version ) { 
  3. if ( ! empty( $data[$version]['comments'] ) ) { 
  4. foreach ( $data[$version]['comments'] as $key => $list ) { 
  5. if ( 'length' !== $key && ! empty( $list ) ) { 
  6. $metadata[$key] = wp_kses_post( reset( $list ) ); 
  7. // Fix bug in byte stream analysis. 
  8. if ( 'terms_of_use' === $key && 0 === strpos( $metadata[$key], 'yright notice.' ) ) 
  9. $metadata[$key] = 'Cop' . $metadata[$key]; 
  10. break; 
  11.  
  12. if ( ! empty( $data['id3v2']['APIC'] ) ) { 
  13. $image = reset( $data['id3v2']['APIC']); 
  14. if ( ! empty( $image['data'] ) ) { 
  15. $metadata['image'] = array( 
  16. 'data' => $image['data'],  
  17. 'mime' => $image['image_mime'],  
  18. 'width' => $image['image_width'],  
  19. 'height' => $image['image_height'] 
  20. ); 
  21. } elseif ( ! empty( $data['comments']['picture'] ) ) { 
  22. $image = reset( $data['comments']['picture'] ); 
  23. if ( ! empty( $image['data'] ) ) { 
  24. $metadata['image'] = array( 
  25. 'data' => $image['data'],  
  26. 'mime' => $image['image_mime'] 
  27. );