begin_fetch_post_thumbnail_html
云策文档标注
概述
begin_fetch_post_thumbnail_html 是一个 WordPress 动作钩子,在获取文章缩略图 HTML 之前触发,允许开发者进行即时过滤。
关键要点
- 触发时机:在 wp_get_attachment_image() 函数中所有过滤器应用之前执行。
- 参数:包括文章 ID、缩略图 ID 和图像尺寸,支持注册的尺寸名称或像素数组。
- 用途:常用于自定义缩略图生成逻辑或添加额外处理。
代码示例
do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size );注意事项
- 此钩子自 WordPress 2.9.0 版本引入。
- 与 get_the_post_thumbnail() 函数相关,用于检索文章缩略图。
原文内容
Fires before fetching the post thumbnail HTML.
Description
Provides “just in time” filtering of all filters in wp_get_attachment_image() .
Parameters
$post_idint-
The post ID.
$post_thumbnail_idint-
The post thumbnail 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
do_action( 'begin_fetch_post_thumbnail_html', $post->ID, $post_thumbnail_id, $size );
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |