返回介绍

wp_update_attachment_metadata()

发布于 2017-09-11 13:02:22 字数 3205 浏览 1318 评论 0 收藏 0

wp_update_attachment_metadata( int $post_id,  array $data )

Update metadata for an attachment.


description


参数

$post_id

(int) (Required) Attachment ID.

$data

(array) (Required) Attachment data.


返回值

(int|bool) False if $post is invalid.


源代码

File: wp-includes/post.php

function wp_update_attachment_metadata( $post_id, $data ) {
	$post_id = (int) $post_id;
	if ( !$post = get_post( $post_id ) )
		return false;

	/**
	 * Filters the updated attachment meta data.
	 *
	 * @since 2.1.0
	 *
	 * @param array $data    Array of updated attachment meta data.
	 * @param int   $post_id Attachment ID.
	 */
	if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
	else
		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/plugin.php: apply_filters()
  • wp-includes/post.php: wp_update_attachment_metadata
  • wp-includes/post.php: update_post_meta()
  • wp-includes/post.php: delete_post_meta()
  • wp-includes/post.php: get_post()

Used By

  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::import_theme_starter_content()
  • wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php: WP_REST_Attachments_Controller::create_item()
  • wp-admin/includes/class-wp-site-icon.php: WP_Site_Icon::insert_attachment()
  • wp-admin/includes/ajax-actions.php: wp_ajax_crop_image()
  • wp-admin/includes/image-edit.php: wp_restore_image()
  • wp-admin/includes/image-edit.php: wp_save_image()
  • wp-admin/includes/image.php: wp_generate_attachment_metadata()
  • wp-admin/includes/media.php: media_handle_upload()
  • wp-admin/includes/media.php: media_handle_sideload()
  • wp-admin/includes/post.php: edit_post()
  • wp-admin/includes/ajax-actions.php: wp_ajax_save_attachment()
  • wp-admin/custom-header.php: Custom_Image_Header::insert_attachment()
  • wp-admin/custom-header.php: Custom_Image_Header::step_2()
  • wp-admin/custom-background.php: Custom_Background::handle_upload()
  • wp-includes/media.php: wp_maybe_generate_attachment_metadata()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::mw_newMediaObject()
  • Show 11 more used by Hide more used by

User Contributed Notes

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

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

发布评论

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