@@ -185,7 +185,16 @@ public function test_shortcodes_recipe_image_shortcode_src() {
185185 $ content = '[recipe-image https://example.com] ' ;
186186
187187 $ shortcode_content = do_shortcode ( $ content );
188- $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" src="https://example.com" /> ' , $ shortcode_content );
188+
189+ // We expect a different image markup in WP 5.5 when Lazy Load is enabled.
190+ if (
191+ function_exists ( 'wp_lazy_loading_enabled ' )
192+ && wp_lazy_loading_enabled ( 'img ' , 'wp_get_attachment_image ' )
193+ ) {
194+ $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" loading="lazy" src="https://example.com" /> ' , $ shortcode_content );
195+ } else {
196+ $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" src="https://example.com" /> ' , $ shortcode_content );
197+ }
189198 }
190199
191200 /**
@@ -198,7 +207,16 @@ public function test_shortcodes_recipe_image_shortcode_src_attr() {
198207 $ content = '[recipe-image image="https://example.com"] ' ;
199208
200209 $ shortcode_content = do_shortcode ( $ content );
201- $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" src="https://example.com" /> ' , $ shortcode_content );
210+
211+ // We expect a different image markup in WP 5.5 when Lazy Load is enabled.
212+ if (
213+ function_exists ( 'wp_lazy_loading_enabled ' )
214+ && wp_lazy_loading_enabled ( 'img ' , 'wp_get_attachment_image ' )
215+ ) {
216+ $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" loading="lazy" src="https://example.com" /> ' , $ shortcode_content );
217+ } else {
218+ $ this ->assertContains ( '<img class="jetpack-recipe-image u-photo photo" itemprop="image" src="https://example.com" /> ' , $ shortcode_content );
219+ }
202220 }
203221
204222 /**
@@ -245,7 +263,7 @@ public function test_shortcodes_recipe_image_shortcode_attachment() {
245263 $ content = '[recipe-image ' . $ attachment_id . '] ' ;
246264
247265 $ shortcode_content = do_shortcode ( $ content );
248- $ this ->assertContains ( '<img src="http://example.org/wp-content/uploads/example.jpg" class="jetpack-recipe-image u-photo photo" alt="" itemprop="image" /> ' , $ shortcode_content );
266+ $ this ->assertContains ( '<img src="http://example.org/wp-content/uploads/example.jpg" class="jetpack-recipe-image u-photo photo" ' , $ shortcode_content );
249267 }
250268
251269 /**
@@ -268,7 +286,7 @@ public function test_shortcodes_recipe_image_shortcode_attachment_attr() {
268286 $ content = '[recipe-image image=" ' . $ attachment_id . '"] ' ;
269287
270288 $ shortcode_content = do_shortcode ( $ content );
271- $ this ->assertContains ( '<img src="http://example.org/wp-content/uploads/example.jpg" class="jetpack-recipe-image u-photo photo" alt="" itemprop="image" /> ' , $ shortcode_content );
289+ $ this ->assertContains ( '<img src="http://example.org/wp-content/uploads/example.jpg" class="jetpack-recipe-image u-photo photo" ' , $ shortcode_content );
272290 }
273291
274292 /**
0 commit comments