Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Image block: Conditionally remove empty <figcaption>
  • Loading branch information
ockham committed Oct 2, 2025
commit b756c185bfc2eda922418738b1b38557ec6763ea
8 changes: 8 additions & 0 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ function render_block_core_image( $attributes, $content, $block ) {
$p->set_attribute( 'data-id', $data_id );
}

/*
* If the caption attribute is empty (which might happen if it is bound to a block
* bindings source), remove the `<figcaption>` element so it isn't rendered empty.
*/
if ( empty( $attributes['caption'] ) && $p->next_tag( 'figcaption' ) ) {
// TODO: Remove <figcaption>.
}

$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
$lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block );

Expand Down