Category: Comments
snip_FetchPriority version 10
add_action(‘template_redirect’, function () { ob_start(function ($html) { return preg_replace_callback( ‘#]+class=”[^”]*highfetchprio[^”]*”[^>]*)>#i’, function ($matches) { $img = $matches[0]; // ✅ Supprimer lazyload et attributs inutiles $img = preg_replace(‘#slazyload(ed)?#i’, ”, $img); $img = preg_replace(‘#sdata-lazy-[a-z]+=”[^”]*”#i’, ”, $img); // ✅ Supprimer anciens attributs $img =…Continue reading
snip_FetchPriority version 9
add_filter(‘wp_get_attachment_image_attributes’, function ($attr, $attachment) { if (!empty($attr[‘class’]) && strpos($attr[‘class’], ‘highfetchprio’) !== false) { // ✅ Optimisations LCP $attr[‘fetchpriority’] = ‘high’; $attr[‘loading’] = ‘eager’; $attr[‘decoding’] = ‘async’; // ✅ Suppression complète des traces de lazyload $attr[‘class’] = str_replace([‘lazyloaded’, ‘lazyload’], ”, $attr[‘class’]);…Continue reading
snip_FetchPriority version 8
add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset($attr[‘class’]) && strpos($attr[‘class’], ‘highfetchprio’) !== false ) { // Optimisations LCP $attr[‘fetchpriority’] = ‘high’; $attr[‘loading’] = ‘eager’; $attr[‘decoding’] = ‘async’; // Supprimer toute trace lazyload HTML $attr[‘class’] = str_replace([‘lazyloaded’, ‘lazyload’], ”,…Continue reading
snip_FetchPriority version 7
add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset($attr[‘class’]) && strpos($attr[‘class’], ‘highfetchprio’) !== false ) { // Optimisations LCP $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; // Supprimer toute trace lazyload HTML $attr[‘class’] = str_replace([‘lazyloaded’, ‘lazyload’], ”,…Continue reading
Force_Fin_LazyMob
document.addEventListener(“DOMContentLoaded”, function() { document.querySelectorAll(‘img.highfetchprio’).forEach(function(img) { img.classList.remove(‘lazyloaded’, ‘lazyload’); img.removeAttribute(‘data-lazy-src’); img.removeAttribute(‘data-lazy-srcset’); img.removeAttribute(‘data-lazy-sizes’); img.setAttribute(‘loading’, ‘eager’); img.setAttribute(‘fetchpriority’, ‘high’); }); });Continue reading
snip_FetchPriority version 6
add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset($attr[‘class’]) && strpos($attr[‘class’], ‘highfetchprio’) !== false ) { // Optimisations LCP $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; // Supprimer toute trace lazyload HTML $attr[‘class’] = str_replace([‘lazyloaded’, ‘lazyload’], ”,…Continue reading
snip_FetchPriority version 5
add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { // Optimisations LCP $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; // Supprimer lazyload (desktop + mobile) if…Continue reading
snip_FetchPriority version 4
add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { // Optimisations LCP $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; // Supprimer les classes de lazyload if…Continue reading
snip_FetchPriority version 3
// 1. Modifier les attributs des images avec la classe highfetchprio + supprimer lazyload add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { // Optimisations LCP $attr[‘loading’] =…Continue reading