wp_get_attachment_id3_keys

函数
wp_get_attachment_id3_keys ( $attachment, $context = 'display' )
参数
  • (WP_Post) $attachment The current attachment, provided for context.
    Required:
  • (string) $context Optional. The context. Accepts 'edit', 'display'. Default 'display'.
    Required:
    Default: 'display'
返回值
  • (string[]) Key/value pairs of field keys to labels.
定义位置
相关方法
wp_get_attachment_linkwp_get_attachment_imagewp_get_attachment_image_srcwp_delete_attachment_fileswp_get_attachment_url
引入
3.9.0
弃用
-

wp_get_attachment_id3_keys: 这个函数返回一个特定音频文件的ID3键数组。

返回有用的键,用于从一个附件的存储元数据中查找数据。

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 );
}

常见问题

FAQs
查看更多 >