Skip to content

Commit bd08b9e

Browse files
committed
refactor: streamline lazyload image checks by removing viewport condition
- Removed the check for images in all viewports from the lazyload replacer. - Simplified logging to focus on LCP images only. - Adjusted conditions for skipping lazyload based on LCP status.
1 parent e94b426 commit bd08b9e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

inc/lazyload_replacer.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,16 @@ public function can_lazyload_for( $url, $tag = '' ) {
460460

461461
if ( $this->settings->is_lazyload_type_viewport() ) {
462462
$image_id = $this->get_id_by_url( $url );
463-
$is_in_all_viewports = Optml_Manager::instance()->page_profiler->is_in_all_viewports( $image_id );
464463
$is_lcp_image = Optml_Manager::instance()->page_profiler->is_lcp_image_in_all_viewports( $image_id );
465464
$no_viewport_data_available = ! Optml_Manager::instance()->page_profiler->is_data_available();
466465

467466
if ( OPTML_DEBUG ) {
468-
if ( $is_in_all_viewports ) {
469-
do_action( 'optml_log', 'Lazyload skipped image is in all viewports ' . $url . '|' . $image_id );
470-
} elseif ( $is_lcp_image ) {
467+
if ( $is_lcp_image ) {
471468
do_action( 'optml_log', 'Lazyload skipped image is LCP ' . $url . '|' . $image_id );
472469
}
473470
}
474471

475-
if ( $is_in_all_viewports || $is_lcp_image ) {
472+
if ( $is_lcp_image ) {
476473
Links::add_id( $image_id, 'high' ); // collect ID for preload.
477474
return false;
478475
}

0 commit comments

Comments
 (0)