diff --git a/assets/js/3rd/plugin-jetpack.js b/assets/js/3rd/plugin-jetpack.js index 3d4bc0f1..32fc46f2 100644 --- a/assets/js/3rd/plugin-jetpack.js +++ b/assets/js/3rd/plugin-jetpack.js @@ -27,6 +27,9 @@ $(document).on('loadedNewItems.vpf', function (event) { }); // Fix masonry reloading when Jetpack images lazy loaded. +// https://github.com/Automattic/jetpack/issues/9595 +// +// p.s. it looks like this fix is not working at all in Safari browser. const runReLayout = debounce(200, ($gallery) => { $gallery.vpf('imagesLoaded'); }); diff --git a/classes/3rd/plugins/class-jetpack.php b/classes/3rd/plugins/class-jetpack.php index f2a35147..b2c29b52 100644 --- a/classes/3rd/plugins/class-jetpack.php +++ b/classes/3rd/plugins/class-jetpack.php @@ -34,7 +34,7 @@ public function wp_enqueue_scripts() { return; } - Visual_Portfolio_Assets::register_script( 'visual-portfolio-3rd-jetpack', 'assets/js/3rd/plugin-jetpack.min', array( 'jquery' ) ); + Visual_Portfolio_Assets::register_script( 'visual-portfolio-3rd-jetpack', 'build/assets/js/3rd/plugin-jetpack', array( 'jquery' ) ); $wp_scripts->registered[ $jetpack_ll_handler ]->deps[] = 'visual-portfolio-3rd-jetpack'; } diff --git a/classes/class-images.php b/classes/class-images.php index ad40fa3a..b61a99be 100644 --- a/classes/class-images.php +++ b/classes/class-images.php @@ -437,7 +437,7 @@ public static function process_image_attributes( $attributes ) { $attributes['data-src'] = $attributes['src']; - if ( isset( $attributes['srcset'] ) ) { + if ( ! empty( $attributes['srcset'] ) ) { $attributes['data-srcset'] = $attributes['srcset']; if ( $placeholder ) { diff --git a/tests/phpunit/unit/test-class-images.php b/tests/phpunit/unit/test-class-images.php index 8293fd83..39cd2c5a 100644 --- a/tests/phpunit/unit/test-class-images.php +++ b/tests/phpunit/unit/test-class-images.php @@ -87,6 +87,17 @@ public function test_lazy_loading_srcset_sizes_attributes() { $image_string = 'Test Image'; $lazy_string = 'Test Image'; + $this->assertEquals( + $this->get_noscript_image( $image_string ) . $lazy_string, + Visual_Portfolio_Images::add_image_placeholders( + $image_string + ) + ); + + // When srcset exists, but it is empty. + $image_string = 'Test Image'; + $lazy_string = 'Test Image'; + $this->assertEquals( $this->get_noscript_image( $image_string ) . $lazy_string, Visual_Portfolio_Images::add_image_placeholders(