Skip to content

Commit

Permalink
Make sure we're getting post_content for the displayed attachment in …
Browse files Browse the repository at this point in the history
…the advanced gallery component
  • Loading branch information
razwan committed Oct 7, 2020
1 parent 723fc14 commit 931f2a4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand All @@ -847,15 +853,15 @@ function novablocks_render_advanced_gallery( $attributes ) {

echo '</div>';

if ( ! empty( $image['caption'] ) || ! empty( $attachment->post_content ) ) {
if ( $has_caption || $has_description ) {

echo '<div class="novablocks-advanced-gallery__grid-item-info">';

if ( ! empty( $image['caption'] ) ) {
if ( $has_caption ) {
echo '<div class="novablocks-advanced-gallery__grid-item-caption">' . $image['caption'] . '</div>';
}

if ( ! empty( $attachment->post_content ) ) {
if ( $has_description ) {
echo '<div class="novablocks-advanced-gallery__grid-item-description">' . $attachment->post_content . '</div>';
}

Expand Down

0 comments on commit 931f2a4

Please sign in to comment.