Skip to content

Conversation

@ockham
Copy link
Owner

@ockham ockham commented Aug 20, 2025

Experiment, based on WordPress#9469.

Explores "conditional" Block Bindings, using the example of the Image block's caption attribute. The following cases need to be supported when that attribute is bound to a Block Bindings source:

  • If the block was saved with a caption, and the Block Bindings source value is not empty, the caption is replaced with the latter.
  • If the block was saved with a caption, and the Block Bindings source value is empty, the <figcaption> element is removed.
  • If the block was saved without a caption, and the Block Bindings source value is not empty, a <figcaption> element is added (with the caption set to the Block Bindings source value).
    • We might implement this by changing save.js to always include a <figcaption> -- even if the caption attribute is empty -- and running the logic from the case described directly above.

Trac ticket:


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@ockham
Copy link
Owner Author

ockham commented Sep 2, 2025

Closing in favor of WordPress#9702.

@ockham ockham closed this Sep 2, 2025
@ockham ockham deleted the try/block-binding-conditional-image-caption branch September 2, 2025 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants