image_downsize
云策文档标注
概述
image_downsize 过滤器用于在 image_downsize() 函数输出前进行拦截,允许开发者自定义图像缩放行为。通过返回真值,可以短路默认的图像尺寸处理流程。
关键要点
- 过滤器名称:image_downsize
- 作用:预占 image_downsize() 的输出,返回真值可跳过默认图像缩放
- 参数:$downsize(布尔或数组,是否短路)、$id(附件 ID)、$size(请求的图像尺寸,可为注册尺寸名或宽高数组)
- 源调用:apply_filters( 'image_downsize', false, $id, $size )
- 相关函数:wp_prepare_attachment_for_js() 和 image_downsize()
- 引入版本:WordPress 2.5.0
原文内容
Filters whether to preempt the output of image_downsize() .
Description
Returning a truthy value from the filter will effectively short-circuit down-sizing the image, returning that value instead.
Parameters
$downsizebool|array-
Whether to short-circuit the image downsize.
$idint-
Attachment ID for image.
$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
$out = apply_filters( 'image_downsize', false, $id, $size );
Changelog
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |