钩子文档

load_image_to_edit

💡 云策文档标注

概述

load_image_to_edit 是一个 WordPress 过滤器,用于在编辑时加载当前图像资源。它允许开发者修改图像资源、附件 ID 或尺寸参数。

关键要点

  • 过滤器名称:load_image_to_edit
  • 参数:$image(当前图像资源,类型为 GdImage)、$attachment_id(附件 ID,整数)、$size(请求的图像尺寸,可以是注册的尺寸名称或像素宽高数组)
  • 用法:通过 apply_filters 调用,例如在 load_image_to_edit() 函数中
  • 相关函数:load_image_to_edit() 位于 wp-admin/includes/image.php,用于加载编辑用的图像资源
  • 版本历史:自 WordPress 2.9.0 引入

📄 原文内容

Filters the current image being loaded for editing.

Parameters

$imageresource|GdImage
Current image.
$attachment_idint
Attachment ID.
$sizestring|int[]
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).

Source

$image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );

Changelog

Version Description
2.9.0 Introduced.