Make WordPress Core

Opened 3 weeks ago

Last modified 5 days ago

#65111 new enhancement

Twenty Sixteen: Center text in image captions

Reported by: gaelbonithon's profile gaelbonithon Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.4
Component: Bundled Theme Keywords: has-patch close 2nd-opinion
Focuses: css Cc:

Description

It seems to me that this would be a better default choice. Ideally, we should be able to change it via the UI, but as far as I know, that’s not possible at the moment. One workaround is to use a centered paragraph via the code editor, which feels like a hack.

Attachments (1)

image-block-style-text-center.png (99.2 KB) - added by sabernhardt 5 days ago.
Block style variation for centering caption text in the theme

Download all attachments as: .zip

Change History (7)

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


3 weeks ago
#1

  • Keywords has-patch added

It seems to me that this would be a better default choice. Ideally, we should be able to change it via the UI, but as far as I know, that's not possible at the moment. One workaround is to use a centered paragraph via the code editor, which feels like a hack.

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

## Use of AI Tools

#2 @manhar
3 weeks ago

Tested with patch and it is working as expected.

Refer below images :

Before Patch :
https://postimg.cc/wRN8Tdr9

After Patch :
https://postimg.cc/TyKkXJFY

#3 follow-up: @sabernhardt
3 weeks ago

  • Keywords close added
  • Version changed from trunk to 4.4

The default styling probably should not change after the theme has been publicly available (for ten years). In this case, the theme documentation even shows the image caption text aligned to the left (in a left-to-right language).

The Gutenberg repository has an old issue about adding text alignment controls for captions:
https://github.com/WordPress/gutenberg/issues/12997

#4 in reply to: ↑ 3 @gaelbonithon
3 weeks ago

Replying to sabernhardt:

The default styling probably should not change after the theme has been publicly available (for ten years). In this case, the theme documentation even shows the image caption text aligned to the left (in a left-to-right language).

The Gutenberg repository has an old issue about adding text alignment controls for captions:
https://github.com/WordPress/gutenberg/issues/12997

Yes, I understand, thanks for the pointer. I'll leave it to you to close the ticket/PR…

#5 @sabernhardt
5 days ago

  • Keywords 2nd-opinion added

I almost closed the ticket, but I thought of another possibility to consider first.

To add a control for the user to select text alignment, a block style variation could be added in twentysixteen_setup().

register_block_style(
	'core/image',
	array(
		'name'         => 'caption-center',
		'label'        => __( 'Text align center', 'twentysixteen' ),
		'inline_style' => '.wp-block-image.is-style-caption-center figcaption { text-align: center; }',
	)
);

It still would not be available for someone who wants the Rounded style, and it is not as efficient as creating a control for use with any theme (GB12997).

@sabernhardt
5 days ago

Block style variation for centering caption text in the theme

#6 @gaelbonithon
5 days ago

Yeah, that would be nice, although it would obviously be better to have that option regardless of the theme (along with the other alignment options, at least right-aligned). Patch updated.

Note: See TracTickets for help on using tickets.