On this page
wp_get_attachment_id3_keys( WP_Post $attachment, string $context = 'display' ): string[]
Returns useful keys to use to lookup data from an attachment’s stored metadata.
Parameters
$attachmentWP_Post Required-
The current attachment, provided for context.
$contextstring Optional-
The context. Accepts
'edit','display'. Default'display'.Default:
'display'
Return
string[] Key/value pairs of field keys to labels.
Source
File: wp-includes/media.php. View all references
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 );
}
Hooks
- apply_filters( 'wp_get_attachment_id3_keys',
array $fields ,WP_Post $attachment ,string $context ) -
Filters the editable list of keys to look up data from an attachment’s metadata.
Related
Uses
| Uses | Description |
|---|---|
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| _x() wp-includes/l10n.php | Retrieves translated string with gettext context. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| edit_post() wp-admin/includes/post.php | Updates an existing post with values provided in |
| wp_ajax_save_attachment() wp-admin/includes/ajax-actions.php | Ajax handler for updating attachment attributes. |
| attachment_id3_data_meta_box() wp-admin/includes/meta-boxes.php | Displays fields for ID3 data. |
| 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() wp-includes/media.php | Builds the Playlist shortcode output. |
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_attachment_id3_keys