挂钩:content.render.html
Last updated on Jun 23, 2026 11:01
## 概述
类型: 过滤器
位置: app/Services/ContentRenderer.php
从块内容中过滤最终呈现的 HTML 输出。在所有块转换为 HTML 后运行。用于全局内容转换,例如添加目录、延迟加载图像或注入广告。
## 参数
| 参数 | 类型 | 描述 |
|---|---|---|
$html |
string | 完整呈现的 HTML |
$blocks |
array | 原始块数组 |
## 返回
必须返回“字符串”。
使用示例
Hook::addFilter('content.render.html', function (string $html) {
return str_replace('<img ', '<img loading="lazy" ', $html);
});
相关挂钩
- content.render.blocks - 渲染前过滤块数组
- post.content.render - API 资源层中的过滤器