perf(featured-image): Optimize LCP with fetchpriority=high
- Disable lazy loading by default for featured images (LCP element) - Add fetchpriority="high" attribute for faster loading - Remove fetchpriority when lazy loading is enabled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -160,16 +160,18 @@ final class FeaturedImageRenderer implements RendererInterface
|
|||||||
$content = $data['content'] ?? [];
|
$content = $data['content'] ?? [];
|
||||||
|
|
||||||
$imageSize = $content['image_size'] ?? 'roi-featured-large';
|
$imageSize = $content['image_size'] ?? 'roi-featured-large';
|
||||||
$lazyLoading = $content['lazy_loading'] ?? true;
|
$lazyLoading = $content['lazy_loading'] ?? false; // LCP: no lazy por defecto
|
||||||
$linkToMedia = $content['link_to_media'] ?? false;
|
$linkToMedia = $content['link_to_media'] ?? false;
|
||||||
|
|
||||||
$imgAttr = [
|
$imgAttr = [
|
||||||
'class' => 'img-fluid featured-image',
|
'class' => 'img-fluid featured-image',
|
||||||
'alt' => get_the_title(),
|
'alt' => get_the_title(),
|
||||||
|
'fetchpriority' => 'high', // LCP optimization
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($lazyLoading) {
|
if ($lazyLoading) {
|
||||||
$imgAttr['loading'] = 'lazy';
|
$imgAttr['loading'] = 'lazy';
|
||||||
|
unset($imgAttr['fetchpriority']); // No fetchpriority si es lazy
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumbnail = get_the_post_thumbnail(null, $imageSize, $imgAttr);
|
$thumbnail = get_the_post_thumbnail(null, $imageSize, $imgAttr);
|
||||||
|
|||||||
Reference in New Issue
Block a user