Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 8 months ago

#64031 closed enhancement (fixed)

Image Block: Add Block Bindings support for caption attribute

Reported by: bernhard-reiter's profile Bernhard Reiter Owned by: bernhard-reiter's profile Bernhard Reiter
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests gutenberg-merge
Focuses: Cc:

Description

The Image block's caption attribute is a bit different from attributes previosuly supported by Block Bindings in that if it is present, a <figcaption> HTML element is saved as part of the HTML markup (which isn't there if the attribute is empty).

This behavior should be mimicked as closely as possible when the attribute is bound to a Block Bindings source instead. This can be partly done by including the <figcaption> in the saved HTML if the attribute is bound, and to have the <figcaption> element's inner HTML replaced by the value provided by the Block Bindings source upon render.

If the Block Bindings source returns an empty value for the caption, we might want to remove the <figcaption> element before rendering.

Change History (3)

This ticket was mentioned in PR #9949 on WordPress/wordpress-develop by @Bernhard Reiter.


9 months ago
#1

  • Keywords has-patch has-unit-tests added

Supersedes https://github.com/WordPress/wordpress-develop/pull/9702 for reasons stated here.

TODO:

Trac ticket: https://core.trac.wordpress.org/ticket/64031

#2 @Bernhard Reiter
9 months ago

  • Owner set to Bernhard Reiter
  • Resolution set to fixed
  • Status changed from assigned to closed

In 60798:

Block Bindings: Support Image block's caption attribute.

This is now possible thank to the logic added in [60684].

Props bernhard-reiter, mukesh27.
Fixes #64031.

#3 @wildworks
8 months ago

  • Keywords gutenberg-merge added
Note: See TracTickets for help on using tickets.