钩子文档

wp_ajax_cropped_attachment_id

💡 云策文档标注

概述

wp_ajax_cropped_attachment_id 是一个 WordPress 过滤器,用于在 AJAX 裁剪图像时修改裁剪后图像的附件 ID。它允许开发者在特定上下文中自定义附件 ID 的处理。

关键要点

  • 这是一个过滤器 Hook,名称为 wp_ajax_cropped_attachment_id。
  • 接受两个参数:$attachment_id(裁剪图像的附件 ID,整数类型)和 $context(请求裁剪图像的 Customizer 控件上下文,字符串类型)。
  • 主要用于 wp_ajax_crop_image() 函数中,处理 AJAX 图像裁剪操作。
  • 自 WordPress 4.3.0 版本引入。

代码示例

$attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context );

📄 原文内容

Filters the attachment ID for a cropped image.

Parameters

$attachment_idint
The attachment ID of the cropped image.
$contextstring
The Customizer control requesting the cropped image.

Source

$attachment_id = apply_filters( 'wp_ajax_cropped_attachment_id', $attachment_id, $context );

Changelog

Version Description
4.3.0 Introduced.