wp_omit_loading_attr_threshold()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_omit_loading_attr_threshold( bool $force = false ): int
Описание
Запускает фильтр ‘wp_omit_loading_attr_threshold’, использующий пороговое значение по умолчанию, равное 3.
Фильтр запускается только один раз за загрузку страницы, если не используется параметр $force.
Оригинал (английский)
This function runs the ‘wp_omit_loading_attr_threshold’ filter, which uses a default threshold value of 3.
The filter is only run once per page load, unless the $force parameter is used.
Параметры
$force
bool
необязательный
= false
Возвращаемое значение
int
Исходный код
wp-includes/media.php:6239
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
* @since 6.3.0 The default threshold was changed from 1 to 3.
*
* @param int $omit_threshold The number of media elements where the `loading` attribute will not be added. Default 3.
*/
$omit_threshold = apply_filters( 'wp_omit_loading_attr_threshold', 3 );
}
return $omit_threshold;
}
История изменений
| Версия | Описание |
|---|---|
| 5.9.0 | Introduced. |

