/* Prioritize only the homepage LCP image; keep all other images lazy-loaded. */ add_filter( 'wp_get_attachment_image_attributes', function ( $attr, $attachment, $size ) { if ( ! is_front_page() || is_paged() || empty( $GLOBALS['wp_query']->posts[0] ) ) { return $attr; } $first_post_id = (int) $GLOBALS['wp_query']->posts[0]->ID; $thumbnail_id = (int) get_post_thumbnail_id( $first_post_id ); if ( ! $thumbnail_id || (int) $attachment->ID !== $thumbnail_id ) { return $attr; } $attr['loading'] = 'eager'; $attr['fetchpriority'] = 'high'; if ( empty( $attr['alt'] ) || ' (Eklenmemiş) görseli' === $attr['alt'] || '(Eklenmemiş) görseli' === $attr['alt'] ) { $attr['alt'] = wp_strip_all_tags( get_the_title( $first_post_id ) ) . ' görseli'; } return $attr; }, 10, 3 );
Ben Burak KUTBAY
👨💻 Software Engineering Team Lead & Blogger
Java ve Java teknolojileriyle sürdürülebilir yazılımlar geliştiriyorum.
Öğrendiklerimi paylaşmayı seviyor, yıllardır blogumda ve sosyal medyada içerik üretiyorum.
Sosyal medya hesaplarımdan beni takip edebilirsin: