From 0784872adc284ab25e0daad507e59f1ab85c5b0a Mon Sep 17 00:00:00 2001 From: Juanma Rodriguez Escriche Date: Thu, 3 Oct 2024 11:18:18 +0200 Subject: [PATCH] Shortcodes: Fix warning when attachment src is false in shortcodes module (#39601) * Check if the attachment is false, to avoid warnings --- .../update-fix-warning-attachnment-src-shortcodes-module | 5 +++++ projects/plugins/jetpack/modules/shortcodes/slideshow.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/update-fix-warning-attachnment-src-shortcodes-module diff --git a/projects/plugins/jetpack/changelog/update-fix-warning-attachnment-src-shortcodes-module b/projects/plugins/jetpack/changelog/update-fix-warning-attachnment-src-shortcodes-module new file mode 100644 index 0000000000000..b563983a8a262 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-fix-warning-attachnment-src-shortcodes-module @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Minor check to avoid Warnings + + diff --git a/projects/plugins/jetpack/modules/shortcodes/slideshow.php b/projects/plugins/jetpack/modules/shortcodes/slideshow.php index 81fffbb0a26cf..1dc48e5c1c8ef 100644 --- a/projects/plugins/jetpack/modules/shortcodes/slideshow.php +++ b/projects/plugins/jetpack/modules/shortcodes/slideshow.php @@ -139,7 +139,7 @@ public function shortcode_callback( $attr ) { $gallery = array(); foreach ( $attachments as $attachment ) { $attachment_image_src = wp_get_attachment_image_src( $attachment->ID, $attr['size'] ); - $attachment_image_src = $attachment_image_src[0]; // [url, width, height]. + $attachment_image_src = false !== $attachment_image_src ? $attachment_image_src[0] : ''; // [url, width, height]. $attachment_image_title = get_the_title( $attachment->ID ); $attachment_image_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ); /**