钩子文档

wp_save_image_editor_file

💡 云策文档标注

概述

wp_save_image_editor_file 是一个 WordPress 过滤器,用于控制是否跳过保存图像文件。返回非空值可以短路保存过程,直接返回该值。

关键要点

  • 过滤器名称:wp_save_image_editor_file
  • 作用:允许开发者通过返回非空值来跳过图像文件的保存操作
  • 参数:包括 $override(覆盖值)、$filename(文件名)、$image(WP_Image_Editor 实例)、$mime_type(MIME 类型)和 $post_id(附件文章 ID)
  • 用法示例:在代码中通过 apply_filters 调用,例如在 wp_save_image_file() 函数中
  • 引入版本:WordPress 3.5.0

代码示例

$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );

📄 原文内容

Filters whether to skip saving the image file.

Description

Returning a non-null value will short-circuit the save method, returning that value instead.

Parameters

$overridebool|null
Value to return instead of saving. Default null.
$filenamestring
Name of the file to be saved.
$imageWP_Image_Editor
The image editor instance.
$mime_typestring
The mime type of the image.
$post_idint
Attachment post ID.

Source

$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );

Changelog

Version Description
3.5.0 Introduced.