钩子文档

image_save_pre

💡 云策文档标注

概述

image_save_pre 是一个已弃用的 WordPress 过滤器,用于在将 GD 图像资源流式传输到浏览器前进行过滤。自 WordPress 3.5.0 起,建议使用 image_editor_save_pre 替代。

关键要点

  • 过滤器名称:image_save_pre
  • 参数:$imageresource(GdImage 图像资源)和 $attachment_id(附件文章 ID)
  • 状态:自 3.5.0 版本起已弃用,推荐使用 image_editor_save_pre
  • 相关函数:wp_save_image_file() 和 wp_stream_image()
  • 引入版本:2.9.0,弃用版本:3.5.0

注意事项

开发者应避免在新代码中使用此过滤器,转而使用 image_editor_save_pre 以确保兼容性和最佳实践。


📄 原文内容

Filters the GD image resource to be streamed to the browser.

Parameters

$imageresource|GdImage
Image resource to be streamed.
$attachment_idint
The attachment post ID.

Source

$image = apply_filters_deprecated( 'image_save_pre', array( $image, $attachment_id ), '3.5.0', 'image_editor_save_pre' );

Changelog

Version Description
3.5.0 Deprecated. Use ‘image_editor_save_pre’ instead.
2.9.0 Introduced.