diff --git a/extensions/blocks/slideshow/slideshow.js b/extensions/blocks/slideshow/slideshow.js index 600afe31db91e..11357d3eb94c2 100644 --- a/extensions/blocks/slideshow/slideshow.js +++ b/extensions/blocks/slideshow/slideshow.js @@ -115,6 +115,11 @@ class Slideshow extends Component { }; render() { + // If user has not selected any images, don't print any markup. + if ( ! this.props?.images?.length ) { + return null; + } + const { autoplay, className, delay, effect, images } = this.props; // Note: React omits the data attribute if the value is null, but NOT if it is false. // This is the reason for the unusual logic related to autoplay below. diff --git a/extensions/blocks/slideshow/slideshow.php b/extensions/blocks/slideshow/slideshow.php index 078eb0fcce61a..595ee7c74a86b 100644 --- a/extensions/blocks/slideshow/slideshow.php +++ b/extensions/blocks/slideshow/slideshow.php @@ -52,10 +52,14 @@ function load_assets( $attr, $content ) { * @return string */ function render_amp( $attr ) { + if ( empty( $attr['ids'] ) ) { + return ''; + } + static $wp_block_jetpack_slideshow_id = 0; $wp_block_jetpack_slideshow_id++; - $ids = empty( $attr['ids'] ) ? array() : $attr['ids']; + $ids = $attr['ids']; $autoplay = empty( $attr['autoplay'] ) ? false : true; $extras = array( 'wp-amp-block',