wp_get_attachment_id3_keys

Returns useful keys to use to lookup data from an attachment's stored metadata.

Description

(array) wp_get_attachment_id3_keys( (WP_Post) $attachment, (string) $context = 'display' ); 

Returns (array)

Key/value pairs of field keys to labels.

Parameters (2)

0. $attachment (WP_Post)
The current attachment, provided for context.
1. $context — Optional. (string) => 'display'
The context. Accepts edit,, display.. Default display..

Usage

  1. if ( !function_exists( 'wp_get_attachment_id3_keys' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4. // The current attachment, provided for context. 
  5. $attachment = null; 
  6.  
  7. // Optional. The context. Accepts 'edit', 'display'. Default 'display'. 
  8. $context = 'display'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_get_attachment_id3_keys($attachment, $context); 
  12.  

Defined (1)

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

/wp-includes/media.php  
  1. function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) { 
  2. $fields = array( 
  3. 'artist' => __( 'Artist' ),  
  4. 'album' => __( 'Album' ),  
  5. ); 
  6.  
  7. if ( 'display' === $context ) { 
  8. $fields['genre'] = __( 'Genre' ); 
  9. $fields['year'] = __( 'Year' ); 
  10. $fields['length_formatted'] = _x( 'Length', 'video or audio' ); 
  11. } elseif ( 'js' === $context ) { 
  12. $fields['bitrate'] = __( 'Bitrate' ); 
  13. $fields['bitrate_mode'] = __( 'Bitrate Mode' ); 
  14.  
  15. /** 
  16. * Filters the editable list of keys to look up data from an attachment's metadata. 
  17. * @since 3.9.0 
  18. * @param array $fields Key/value pairs of field keys to labels. 
  19. * @param WP_Post $attachment Attachment object. 
  20. * @param string $context The context. Accepts 'edit', 'display'. Default 'display'. 
  21. */ 
  22. return apply_filters( 'wp_get_attachment_id3_keys', $fields, $attachment, $context );