Title: wp_get_attachment_id3_keys
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_get_attachment_id3_keys( WP_Post $attachment, string $context ): string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#changelog)

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

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

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

 `$attachment`[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
required

The current attachment, provided for context.

`$context`stringoptional

The context. Accepts `'edit'`, `'display'`. Default `'display'`.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#return)󠁿

 string[] Key/value pairs of field keys to labels.

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

    ```php
    function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) {
    	$fields = array(
    		'artist' => __( 'Artist' ),
    		'album'  => __( 'Album' ),
    	);

    	if ( 'display' === $context ) {
    		$fields['genre']            = __( 'Genre' );
    		$fields['year']             = __( 'Year' );
    		$fields['length_formatted'] = _x( 'Length', 'video or audio' );
    	} elseif ( 'js' === $context ) {
    		$fields['bitrate']      = __( 'Bitrate' );
    		$fields['bitrate_mode'] = __( 'Bitrate Mode' );
    	}

    	/**
    	 * Filters the editable list of keys to look up data from an attachment's metadata.
    	 *
    	 * @since 3.9.0
    	 *
    	 * @param array   $fields     Key/value pairs of field keys to labels.
    	 * @param WP_Post $attachment Attachment object.
    	 * @param string  $context    The context. Accepts 'edit', 'display'. Default 'display'.
    	 */
    	return apply_filters( 'wp_get_attachment_id3_keys', $fields, $attachment, $context );
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_get_attachment_id3_keys’, array $fields, WP_Post $attachment, string $context )](https://developer.wordpress.org/reference/hooks/wp_get_attachment_id3_keys/)

Filters the editable list of keys to look up data from an attachment’s metadata.

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

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

Retrieves the translation of $text.

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

Retrieves translated string with gettext context.

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

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys/?output_format=md#)

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

Updates an existing post with values provided in `$_POST`.

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

Handles updating attachment attributes via AJAX.

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

Displays fields for ID3 data.

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

Prepares an attachment post object for JS, where it is expected to be JSON-encoded and fit into an Attachment model.

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

Builds the Playlist shortcode output.

  |

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

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

## User Contributed Notes

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