钩子文档

image_editor_save_pre

💡 云策文档标注

概述

image_editor_save_pre 是一个 WordPress 过滤器钩子,用于在图像被流式传输到浏览器前,过滤 WP_Image_Editor 实例。它允许开发者在图像保存或流式输出时修改图像编辑器对象。

关键要点

  • 过滤器名称:image_editor_save_pre
  • 参数:$image(WP_Image_Editor 实例)和 $attachment_id(附件文章 ID)
  • 用途:在图像流式传输到浏览器前,对 WP_Image_Editor 实例进行自定义处理
  • 相关函数:wp_save_image_file() 和 wp_stream_image() 使用此钩子
  • 引入版本:WordPress 3.5.0

📄 原文内容

Filters the WP_Image_Editor instance for the image to be streamed to the browser.

Parameters

$imageWP_Image_Editor
The image editor instance.
$attachment_idint
The attachment post ID.

Source

$image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );

Changelog

Version Description
3.5.0 Introduced.