wp_iframe_tag_add_loading_attr
Filter HookDescription
Filters the `loading` attribute value to add to an iframe. Default `lazy`. Returning `false` or an empty string will not add the attribute. Returning `true` will add the default value.Hook Information
| File Location |
wp-includes/media.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 2372 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
string|bool
|
$value
|
The `loading` attribute value. Returning a falsey value will result in the attribute being omitted for the iframe. |
string
|
$iframe
|
The HTML `iframe` tag to be filtered. |
string
|
$context
|
Additional context about how the function was called or where the iframe tag is. |
Usage Examples
Basic Usage
<?php
// Hook into wp_iframe_tag_add_loading_attr
add_filter('wp_iframe_tag_add_loading_attr', 'my_custom_filter', 10, 3);
function my_custom_filter($value, $iframe, $context) {
// Your custom filtering logic here
return $value;
}
Source Code Context
wp-includes/media.php:2372
- How this hook is used in WordPress core
<?php
2367 * @param string|bool $value The `loading` attribute value. Returning a falsey value will result in
2368 * the attribute being omitted for the iframe.
2369 * @param string $iframe The HTML `iframe` tag to be filtered.
2370 * @param string $context Additional context about how the function was called or where the iframe tag is.
2371 */
2372 $value = apply_filters( 'wp_iframe_tag_add_loading_attr', $value, $iframe, $context );
2373
2374 if ( $value ) {
2375 if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) {
2376 $value = 'lazy';
2377 }
PHP Documentation
<?php
/**
* Filters the `loading` attribute value to add to an iframe. Default `lazy`.
*
* Returning `false` or an empty string will not add the attribute.
* Returning `true` will add the default value.
*
* @since 5.7.0
*
* @param string|bool $value The `loading` attribute value. Returning a falsey value will result in
* the attribute being omitted for the iframe.
* @param string $iframe The HTML `iframe` tag to be filtered.
* @param string $context Additional context about how the function was called or where the iframe tag is.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.