wp_get_loading_optimization_attributes

FUNCTION wp-includes\media.php (ligne 5958) github
Gets loading optimization attributes. This function returns an array of attributes that should be merged into the given attributes array to optimize loading performance. Potential attributes returned by this function are: - `loading` attribute with a value of "lazy" - `fetchpriority` attribute with a value of "high" - `decoding` attribute with a value of "async" If any of these attributes are already present in the given attributes, they will not be modified. Note that no element should have both `loading="lazy"` and `fetchpriority="high"`, so the function will trigger a warning in case both attributes are present with those values.

Paramètres

Entrée :
$tag_name, $attr, $context
Sortie :
@param string $tag_name The tag name.
@param array  $attr     Array of the attributes for the tag.
@param string $context  Context for the element for which the loading optimization attribute is requested.
@return array Loading optimization attributes.

Utilisation

// Utilisation de la fonction wp_get_loading_optimization_attributes
$result = wp_get_loading_optimization_attributes($tag_name, $attr, $context);

if ($result) {
    // Votre logique ici
}

Actualités

Chargement des actualités...