From 931f2a460b9830d1162b4ccbbcc656c68fa65b13 Mon Sep 17 00:00:00 2001 From: Razvan Date: Wed, 7 Oct 2020 15:12:38 +0300 Subject: [PATCH] Make sure we're getting post_content for the displayed attachment in the advanced gallery component --- lib/extras.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/extras.php b/lib/extras.php index 202d428de..58016e9c3 100644 --- a/lib/extras.php +++ b/lib/extras.php @@ -821,9 +821,15 @@ function novablocks_render_advanced_gallery( $attributes ) { if ( is_numeric( $image['id'] ) && intval( $image['id'] ) > 0 ) { $attachment = get_post( $image['id'] ); - $attachment_src = wp_get_attachment_image_src( $image['id'], 'novablocks_large' ); + + if ( $attachment->post_type === 'attachment' ) { + $attachment_src = wp_get_attachment_image_src( $image['id'], 'novablocks_large' ); + } } + $has_caption = ! empty( $image['caption'] ); + $has_description = $attachment->post_type === 'attachment' && ! empty( $attachment->post_content ); + $url = ''; if ( ! empty( $attachment_src ) ) { @@ -847,15 +853,15 @@ function novablocks_render_advanced_gallery( $attributes ) { echo ''; - if ( ! empty( $image['caption'] ) || ! empty( $attachment->post_content ) ) { + if ( $has_caption || $has_description ) { echo '