Make WordPress Core

Opened 2 years ago

Last modified 21 months ago

#61466 new defect (bug)

Block Bindings: Add support for image caption

Reported by: santosguillamot Owned by:
Priority: normal Milestone: Future Release
Component: Editor Version: 6.6
Severity: normal Keywords: has-patch
Cc: Focuses:

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 (11)

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


2 years 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:


2 years 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:


2 years 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
2 years ago

  • Component GeneralEditor
  • Description modified (diff)

#5 @ellatrix
2 years ago

  • Milestone Awaiting Review6.7

@santosguillamot commented on PR #6838:


2 years 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:


2 years ago
#7

  • private_set_figcaption_inner_html

I would go with private_set_figcaption_inner_html

@dmsnell commented on PR #6838:


2 years ago
#8

What's the status on this? it seems reasonable at the moment, unless there are concerns still about it coming late in the cycle.

@santosguillamot commented on PR #6838:


2 years ago
#9

What's the status on this? it seems reasonable at the moment, unless there are concerns still about it coming late in the cycle.

It wasn't considered a priority, and I personally didn't find time to push it. It would probably need a small refactor and testing in Gutenberg as well: link.

Taking into account that the last Gutenberg version included in 6.7 beta will be on Sep 18th, I personally don't have the bandwidth to work on it, but I'm happy to help if needed.

#10 @desrosj
22 months ago

  • Milestone 6.7Future Release

It seems that this one still requires some work before it can be considered, so pushing to Future Release. If I am misunderstanding the status, please feel free to clarify and move back.

@jonsurrell commented on PR #6838:


21 months ago
#11

@SantosGuillamot and I did some work on an implementation leveraging the HTML processor and using a set_inner_html implementation in https://github.com/WordPress/wordpress-develop/pull/7742.

Note: See TracTickets for help on using tickets.