wp_omit_loading_attr_threshold
函数
wp_omit_loading_attr_threshold ( $force = false )
- 参数
-
-
(bool)
$force
Optional. If set to true, the filter will be (re-)applied even if it already has been before. Default false.- Required: 否
- Default: false
-
(bool)
- 返回值
-
- (int) The number of content media elements to not lazy-load.
- 定义位置
-
-
wp-includes/media.php
, line 5463
-
wp-includes/media.php
- 引入
- 5.9.0
- 弃用
- –
Gets the threshold for how many of the first content media elements to not lazy-load.
This function runs the {@see ‘wp_omit_loading_attr_threshold’} filter, which uses a default threshold value of 1.
The filter is only run once per page load, unless the `$force` parameter is used.
function wp_omit_loading_attr_threshold( $force = false ) { static $omit_threshold; // This function may be called multiple times. Run the filter only once per page load. if ( ! isset( $omit_threshold ) || $force ) { /** * Filters the threshold for how many of the first content media elements to not lazy-load. * * For these first content media elements, the `loading` attribute will be omitted. By default, this is the case * for only the very first content media element. * * @since 5.9.0 * * @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 1. */ $omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 1 ); } return $omit_threshold; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。