wp_lazy_loading_enabled

The timeline below displays how wordpress function wp_lazy_loading_enabled has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Determines whether to add the `loading` attribute to the specified tag in the specified context.
 *
 * @since 5.5.0
 * @since 5.7.0 Now returns `true` by default for `iframe` tags.
 *
 * @param string $tag_name The tag name.
 * @param string $context  Additional context, like the current filter name
 *                         or the function name from where this was called.
 * @return bool Whether to add the attribute.
 */
function wp_lazy_loading_enabled($tag_name, $context)
{
    /*
     * By default add to all 'img' and 'iframe' tags.
     * See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading
     * See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-loading
     */
    $default = 'img' === $tag_name || 'iframe' === $tag_name;
    /**
     * Filters whether to add the `loading` attribute to the specified tag in the specified context.
     *
     * @since 5.5.0
     *
     * @param bool   $default  Default value.
     * @param string $tag_name The tag name.
     * @param string $context  Additional context, like the current filter name
     *                         or the function name from where this was called.
     */
    return (bool) apply_filters('wp_lazy_loading_enabled', $default, $tag_name, $context);
}

WordPress Version: 5.7

/**
 * Determines whether to add the `loading` attribute to the specified tag in the specified context.
 *
 * @since 5.5.0
 * @since 5.7.0 Now returns `true` by default for `iframe` tags.
 *
 * @param string $tag_name The tag name.
 * @param string $context  Additional context, like the current filter name
 *                         or the function name from where this was called.
 * @return bool Whether to add the attribute.
 */
function wp_lazy_loading_enabled($tag_name, $context)
{
    // By default add to all 'img' and 'iframe' tags.
    // See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading
    // See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-loading
    $default = 'img' === $tag_name || 'iframe' === $tag_name;
    /**
     * Filters whether to add the `loading` attribute to the specified tag in the specified context.
     *
     * @since 5.5.0
     *
     * @param bool   $default  Default value.
     * @param string $tag_name The tag name.
     * @param string $context  Additional context, like the current filter name
     *                         or the function name from where this was called.
     */
    return (bool) apply_filters('wp_lazy_loading_enabled', $default, $tag_name, $context);
}

WordPress Version: 5.6

/**
 * Determines whether to add the `loading` attribute to the specified tag in the specified context.
 *
 * @since 5.5.0
 *
 * @param string $tag_name The tag name.
 * @param string $context  Additional context, like the current filter name
 *                         or the function name from where this was called.
 * @return bool Whether to add the attribute.
 */
function wp_lazy_loading_enabled($tag_name, $context)
{
    // By default add to all 'img' tags.
    // See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading
    $default = 'img' === $tag_name;
    /**
     * Filters whether to add the `loading` attribute to the specified tag in the specified context.
     *
     * @since 5.5.0
     *
     * @param bool   $default  Default value.
     * @param string $tag_name The tag name.
     * @param string $context  Additional context, like the current filter name
     *                         or the function name from where this was called.
     */
    return (bool) apply_filters('wp_lazy_loading_enabled', $default, $tag_name, $context);
}

WordPress Version: 5.5

/**
 * Determine whether to add the `loading` attribute to the specified tag in the specified context.
 *
 * @since 5.5.0
 *
 * @param string $tag_name The tag name.
 * @param string $context  Additional context, like the current filter name or the function name from where this was called.
 * @return bool Whether to add the attribute.
 */
function wp_lazy_loading_enabled($tag_name, $context)
{
    // By default add to all 'img' tags.
    // See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading
    $default = 'img' === $tag_name;
    /**
     * Filters whether to add the `loading` attribute to the specified tag in the specified context.
     *
     * @since 5.5.0
     *
     * @param bool   $default  Default value.
     * @param string $tag_name The tag name.
     * @param string $context  Additional context, like the current filter name or the function name from where this was called.
     */
    return (bool) apply_filters('wp_lazy_loading_enabled', $default, $tag_name, $context);
}