wp_get_attachment_id3_keys() WordPress Function

The wp_get_attachment_id3_keys() function is used to get all ID3 keys for an attachment. These keys can be used to access the data in the attachment's ID3 tags.

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

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


Parameters

$attachment

(WP_Post)(Required)The current attachment, provided for context.

$context

(string)(Optional) The context. Accepts 'edit', 'display'.

Default value: 'display'


Top ↑

Return

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


Top ↑

Source

File: wp-includes/media.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 );
}


Top ↑

Changelog

Changelog
VersionDescription
3.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More