From ce0f4855a5b005cc88ad6d68f74e5c8140c51a57 Mon Sep 17 00:00:00 2001 From: Camilla Krag Jensen Date: Sun, 16 Feb 2025 18:04:30 +0100 Subject: [PATCH 1/3] fix(perfmatters): default for lazyload img setting Add Jetpack Image Compare's block class to parent selector exclusions --- includes/plugins/class-perfmatters.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/includes/plugins/class-perfmatters.php b/includes/plugins/class-perfmatters.php index 7abefc2149..e806913177 100644 --- a/includes/plugins/class-perfmatters.php +++ b/includes/plugins/class-perfmatters.php @@ -223,6 +223,19 @@ private static function get_defaults( $options = [] ) { $options['lazyload']['youtube_preview_thumbnails'] = true; $options['lazyload']['image_dimensions'] = true; + + if ( empty( $options['lazyload']['lazy_loading_parent_exclusions'] ) ) { + $options['lazyload']['lazy_loading_parent_exclusions'] = []; + } + // Add our customizations to the front of the array to avoid confusion when editing + // the setting in the UI. + $options['lazyload']['lazy_loading_parent_exclusions'] = array_unshift( + $options['lazyload']['lazy_loading_parent_exclusions'], + [ + 'wp-block-jetpack-image-compare', + ] + ); + // Fonts. if ( ! isset( $options['fonts'] ) ) { $options['fonts'] = []; From 43314e7797de080a2ab4d74254876e2994c57128 Mon Sep 17 00:00:00 2001 From: Camilla Krag Jensen Date: Sun, 16 Feb 2025 18:09:38 +0100 Subject: [PATCH 2/3] fix(perfmatters): remove empty line --- includes/plugins/class-perfmatters.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/plugins/class-perfmatters.php b/includes/plugins/class-perfmatters.php index e806913177..40f00f7f2b 100644 --- a/includes/plugins/class-perfmatters.php +++ b/includes/plugins/class-perfmatters.php @@ -223,7 +223,6 @@ private static function get_defaults( $options = [] ) { $options['lazyload']['youtube_preview_thumbnails'] = true; $options['lazyload']['image_dimensions'] = true; - if ( empty( $options['lazyload']['lazy_loading_parent_exclusions'] ) ) { $options['lazyload']['lazy_loading_parent_exclusions'] = []; } From 4e63886d8c56821e14323bb1bab11904d685c029 Mon Sep 17 00:00:00 2001 From: Camilla Krag Jensen Date: Tue, 18 Feb 2025 13:15:29 +0100 Subject: [PATCH 3/3] fix(perfmatters): simplify and fix --- includes/plugins/class-perfmatters.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/plugins/class-perfmatters.php b/includes/plugins/class-perfmatters.php index 40f00f7f2b..d7ce6abfc6 100644 --- a/includes/plugins/class-perfmatters.php +++ b/includes/plugins/class-perfmatters.php @@ -223,16 +223,11 @@ private static function get_defaults( $options = [] ) { $options['lazyload']['youtube_preview_thumbnails'] = true; $options['lazyload']['image_dimensions'] = true; - if ( empty( $options['lazyload']['lazy_loading_parent_exclusions'] ) ) { - $options['lazyload']['lazy_loading_parent_exclusions'] = []; - } - // Add our customizations to the front of the array to avoid confusion when editing - // the setting in the UI. - $options['lazyload']['lazy_loading_parent_exclusions'] = array_unshift( - $options['lazyload']['lazy_loading_parent_exclusions'], - [ - 'wp-block-jetpack-image-compare', - ] + $parent_exclusions = empty( $options['lazyload']['lazy_loading_parent_exclusions'] ) ? [] : $options['lazyload']['lazy_loading_parent_exclusions']; + // Add our customizations to the front of the array to avoid confusion when editing the setting in the UI. + $options['lazyload']['lazy_loading_parent_exclusions'] = array_merge( + [ 'wp-block-jetpack-image-compare' ], + $parent_exclusions ); // Fonts.