wp_iframe_tag_add_loading_attr
云策文档标注
概述
此文档介绍 WordPress 中的 wp_iframe_tag_add_loading_attr 过滤器,用于控制 iframe 标签的 loading 属性值。默认值为 lazy,开发者可通过此过滤器自定义或禁用该属性。
关键要点
- wp_iframe_tag_add_loading_attr 过滤器允许修改 iframe 的 loading 属性值,默认设置为 lazy。
- 返回 false 或空字符串将不添加 loading 属性,返回 true 则使用默认值 lazy。
- 过滤器参数包括 $value(属性值,可为字符串或布尔值)、$iframe(HTML iframe 标签)和 $context(调用上下文)。
- 此过滤器在 WordPress 5.7.0 版本中引入,相关函数 wp_iframe_tag_add_loading_attr() 位于 wp-includes/media.php 文件中。
原文内容
Filters the loading attribute value to add to an iframe. Default lazy.
Description
Returning false or an empty string will not add the attribute.
Returning true will add the default value.
Parameters
$valuestring|bool-
The
loadingattribute value. Returning a falsey value will result in the attribute being omitted for the iframe. $iframestring-
The HTML
iframetag to be filtered. $contextstring-
Additional context about how the function was called or where the iframe tag is.
Source
$value = apply_filters( 'wp_iframe_tag_add_loading_attr', $value, $iframe, $context );
Changelog
| Version | Description |
|---|---|
| 5.7.0 | Introduced. |