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

snip_FetchPriority version 0

add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { // Check if the image has the class “highfetchprio” if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; }…Continue reading

snip_FetchPriority version 2

add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { // Check if the image has the class “highfetchprio” if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; }…Continue reading

Helper Functions (dep)

/** * WPCode Snippet: get_page_by_title Compatibility Helper * * This snippet provides a backward-compatible replacement for the deprecated * get_page_by_title() function that was removed in WordPress 6.2.0 * * To use this snippet: * 1. Go to WPCode > +…Continue reading

snip_FetchPriority

add_action(‘template_redirect’, function () { // On initialise un tableau global $GLOBALS[‘highfetchprio_preload’] = []; ob_start(function ($html) { // 1. On modifie les balises ciblées $html = preg_replace_callback( ‘#]+class=”[^”]*highfetchprio[^”]*”[^>]*)>#i’, function ($matches) { $img = $matches[0]; // Supprimer lazyload et attributs inutiles $img…Continue reading