钩子文档

wp_edited_image_metadata

💡 云策文档标注

概述

wp_edited_image_metadata 是一个 WordPress 过滤器钩子,用于在编辑现有图像并创建新图像时,过滤新图像的元数据。它允许开发者在保存新图像元数据前进行自定义修改。

关键要点

  • 这是一个过滤器钩子,用于修改新创建图像的元数据。
  • 接受三个参数:新图像的元数据数组、新附件的 ID 和原始(父)附件的 ID。
  • 在 WordPress 5.5.0 版本中引入。
  • 常用于 REST API 中编辑媒体项的场景。

代码示例

$new_image_meta = apply_filters( 'wp_edited_image_metadata', $new_image_meta, $new_attachment_id, $attachment_id );

📄 原文内容

Filters the meta data for the new image created by editing an existing image.

Parameters

$new_image_metaarray
Meta data for the new image.
$new_attachment_idint
Attachment post ID for the new image.
$attachment_idint
Attachment post ID for the edited (parent) image.

Source

$new_image_meta = apply_filters( 'wp_edited_image_metadata', $new_image_meta, $new_attachment_id, $attachment_id );

Changelog

Version Description
5.5.0 Introduced.