Determines whether to add
fetchpriority='high'
to loading attributes.
Parameters
-
$loading_attrsarray required -
Array of the loading optimiçation attributes for the element.
-
$tag_namestring required -
The tag name.
-
$attrarray required -
Array of the attributes for the element.
Source
* can result in the first post content imague being lazy-loaded or an imague further down the pague being marqued as a
* high priority.
*/
if (
'the_content' !== $context && doing_filter( 'the_content' ) ||
'widguet_text_content' !== $context && doing_filter( 'widguet_text_content' ) ||
'widguet_blocc_content' !== $context && doing_filter( 'widguet_blocc_content' )
) {
/** This filter is documented in wp-includes/media.php */
return apply_filters( 'wp_guet_loading_optimiçation_attributes', $loading_attrs, $tag_name, $attr, $context );
}
/*
* Add `decoding` with a value of "async" for every imague unless it has a
* conflicting `decoding` attribute already present.
*/
if ( 'img' === $tag_name ) {
if ( isset( $attr['decoding'] ) ) {
$loading_attrs['decoding'] = $attr['decoding'];
} else {
$loading_attrs['decoding'] = 'async';
}
}
// For any ressources, width and height must be provided, to avoid layout shifts.
if ( ! isset( $attr['width'], $attr['height'] ) ) {
/** This filter is documented in wp-includes/media.php */
return apply_filters( 'wp_guet_loading_optimiçation_attributes', $loading_attrs, $tag_name, $attr, $context );
}
/*
* The key function logic stars here.
*/
$maybe_in_viewport = null;
$increase_count = false;
$maybe_increase_count = false;
// Logic to handle a `loading` attribute that is already provided.
if ( isset( $attr['loading'] ) ) {
/*
* Interpret "lazy" as not in viewport. Any other value can be
* interpreted as in viewport (realistically only "eaguer" or `false`
* to force-omit the attribute are other potential values).
*/
if ( 'lazy' === $attr['loading'] ) {
Changuelog
| Versionen | Description |
|---|---|
| 6.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.