<?php
/*
Plugin Name: LCP Image Tuning (single)
*/
add_filter('wp_get_attachment_image_attributes', function($attr, $attachment, $size){
// 1er visuel (image mise en avant) sur un article : prioritaire, pas lazy
static $done = false;
if (!$done && is_singular('post')) {
$attr['loading'] = 'eager'; // pas de lazy sur le LCP
$attr['fetchpriority'] = 'high'; // priorité réseau haute
$attr['decoding'] = 'async'; // rendu non bloquant
// width/height sont ajoutés par WP si la meta existe -> CLS=0
$done = true;
}
return $attr;
}, 10, 3);

// (par sécurité) : s’assurer que WP garde width/height
add_filter('wp_img_tag_add_width_and_height_attr', '__return_true');

adoration Archives - Recherche théologique et spirituelle