Skip to content

Commit bc39bd8

Browse files
authored
Blocks: fix slideshow sizing for lazy-loaded images (#45164)
Fix sizing issue for lazy-loaded images (usually starting with 3rd image) in Slideshow block.
1 parent f69d1f0 commit bc39bd8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: other
3+
4+
Blocks: fix slideshow sizing for lazy-loaded images.

projects/plugins/jetpack/extensions/blocks/slideshow/slideshow.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ function load_assets( $attr, $content ) {
5151
enqueue_swiper_library();
5252
}
5353

54+
// Fix for lazy loading conflict with slideshow images.
55+
if ( ! is_admin() ) {
56+
add_filter(
57+
'wp_content_img_tag',
58+
function ( $image ) {
59+
if ( str_contains( $image, 'loading="lazy"' ) && str_contains( $image, 'wp-block-jetpack-slideshow_image' ) ) {
60+
$image = str_replace( 'sizes="auto, ', 'sizes="', $image );
61+
}
62+
return $image;
63+
}
64+
);
65+
}
66+
5467
return $content;
5568
}
5669

0 commit comments

Comments
 (0)