钩子文档

wp_ajax_crop_image_pre_save

💡 云策文档标注

概述

wp_ajax_crop_image_pre_save 是一个 WordPress 动作钩子,在裁剪后的图像保存之前触发,允许开发者通过添加过滤器来修改保存方式。

关键要点

  • 这是一个动作钩子,用于在图像裁剪保存前执行自定义代码。
  • 提供三个参数:$context(Customizer 控制上下文)、$attachment_id(原始附件 ID)和$cropped(裁剪图像文件路径)。
  • 主要用于 AJAX 图像裁剪处理,与 wp_ajax_crop_image() 函数相关。
  • 从 WordPress 4.3.0 版本开始引入。

代码示例

do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );

📄 原文内容

Fires before a cropped image is saved.

Description

Allows to add filters to modify the way a cropped image is saved.

Parameters

$contextstring
The Customizer control requesting the cropped image.
$attachment_idint
The attachment ID of the original image.
$croppedstring
Path to the cropped image file.

Source

do_action( 'wp_ajax_crop_image_pre_save', $context, $attachment_id, $cropped );

Changelog

Version Description
4.3.0 Introduced.