钩子文档

editor_max_image_size

💡 云策文档标注

概述

editor_max_image_size 是一个 WordPress 过滤器,用于调整编辑器中的最大图像尺寸。它允许开发者自定义图像在编辑器中显示或插入时的宽度和高度限制。

关键要点

  • 过滤器名称:editor_max_image_size
  • 参数:$max_image_size(数组,包含最大宽度和高度值)、$size(请求的图像尺寸,可以是注册的尺寸名称或像素数组)、$context(上下文,如 'display' 或 'edit')
  • 用途:控制图像在编辑器中的缩放,常用于 image_constrain_size_for_editor() 函数
  • 引入版本:WordPress 2.5.0

代码示例

list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size, $context );

📄 原文内容

Filters the maximum image size dimensions for the editor.

Parameters

$max_image_sizeint[]
An array of width and height values.

  • 0 int
    The maximum width in pixels.
  • 1 int
    The maximum height in pixels.

$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).
$contextstring
The context the image is being resized for.
Possible values are 'display' (like in a theme) or 'edit' (like inserting into an editor).

Source

list( $max_width, $max_height ) = apply_filters( 'editor_max_image_size', array( $max_width, $max_height ), $size, $context );

Changelog

Version Description
2.5.0 Introduced.