返回介绍

wp_get_attachment_id3_keys()

发布于 2017-09-11 11:58:54 字数 2626 浏览 883 评论 0 收藏 0

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.


description


参数

$attachment

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

$context

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

Default value: 'display'


返回值

(array) Key/value pairs of field keys to labels.


源代码

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

更新日志

Versiondescription
3.9.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: __()
  • wp-includes/l10n.php: _x()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/media.php: wp_get_attachment_id3_keys

Used By

  • wp-admin/includes/post.php: edit_post()
  • wp-admin/includes/ajax-actions.php: wp_ajax_save_attachment()
  • wp-admin/includes/meta-boxes.php: attachment_id3_data_meta_box()
  • wp-includes/media.php: wp_prepare_attachment_for_js()
  • wp-includes/media.php: wp_playlist_shortcode()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文