Make WordPress Core

Opened 5 weeks ago

Last modified 3 weeks ago

#61466 new defect (bug)

Block Bindings: Add support for image caption

Reported by: santosguillamot's profile santosguillamot Owned by:
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.6
Component: Editor Keywords: has-patch
Focuses: Cc:

Description (last modified by sabernhardt)

Allow the block bindings API to process the image caption attribute and replace its inner content with the value obtained from the source.

There is an issue with pattern overrides caused by this: GB62287.

Additionally, it is a good enhancement.

Change History (7)

This ticket was mentioned in PR #6838 on WordPress/wordpress-develop by @santosguillamot.


5 weeks ago
#1

This pull request should be tested together with this other one from Gutenberg, because it needs changes in the image render file.

## What?

Add support for the image caption attribute in block bindings.

## Why?

There is an issue with pattern overrides caused by this: https://github.com/WordPress/gutenberg/issues/62287.

Additionally, it is a good enhancement.

## How?

I created an anonymous class to extend the tag processor and include set_inner_text until there is a similar method provided by default.

Additionally, in Gutenberg pull request, I'm modifying the render file of the image to:

  • Remove the figcaption element when it exists, and the binding value is empty.
  • Add the figcaption element when it doesn't exist, and the binding value is not empty.

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

@ellatrix commented on PR #6838:


5 weeks ago
#2

I'm quite worried about introducing caption support this late in the release cycle. Imo it deserves some testing as a feature in the GB plugin first. I've made this alternative PR that disallows overrides for an image with caption: https://github.com/WordPress/gutenberg/pull/62747.

@santosguillamot commented on PR #6838:


5 weeks ago
#3

I totally understand the concerns. And I agree that if support for image caption is not added, code to disallowing overrides in images with captions for 6.6 could be a good alternative.

#4 @sabernhardt
5 weeks ago

  • Component changed from General to Editor
  • Description modified (diff)

#5 @ellatrix
4 weeks ago

  • Milestone changed from Awaiting Review to 6.7

@santosguillamot commented on PR #6838:


3 weeks ago
#6

I'd prefer the name of the method be scarier, like seriously_wait_for_core_to_replace_inner_html() but that's just a personal preference.

While I agree we could change the name to prevent users even more from copying it, seriously_wait_for_core_to_replace_inner_html seems too much to me. Here are some other options that, combined withthe warning message, I believe should be scary enough:

  • do_not_copy_set_figcaption_inner_html.
  • private_set_figcaption_inner_html.
  • internal_do_not_use_figcaption_inner_html.

Apart from that, we could always wait to support the image caption until the HTML Processor provides its own method.

Any thoughts?

@cbravobernal commented on PR #6838:


3 weeks ago
#7

  • private_set_figcaption_inner_html

I would go with private_set_figcaption_inner_html

Note: See TracTickets for help on using tickets.