WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

#21848 closed defect (bug) (fixed)

A single space in the image caption breaks alignment

Reported by: luffer Owned by: wonderboymusic
Milestone: 4.2 Priority: low
Severity: trivial Version: 3.4.2
Component: Media Keywords: has-patch dev-feedback
Focuses: Cc:

Description

If you add just a single space in the caption field of an image using the media uploader, it ignores any alignment settings.

The expected behaviour would mean that regardless of what is entered into the caption box, the image alignment should be honoured.

Attachments (2)

21848.diff (1.1 KB) - added by wonderboymusic 4 months ago.
21848.2.diff (839 bytes) - added by boonebgorges 3 months ago.

Download all attachments as: .zip

Change History (13)

comment:2 follow-up: @ericlewis13 months ago

  • Severity changed from normal to trivial

@luffer thanks for the bug report! I can reproduce, but this is trivial.

Maybe we should be trim()ing captions on change in the media modal? Are there use cases where folks want untrimmed captions?

comment:3 @wonderboymusic4 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.2

@wonderboymusic4 months ago

comment:4 @wonderboymusic4 months ago

21848.diff fixes part of this.

comment:5 @samuelsidler3 months ago

  • Priority changed from normal to low

comment:6 @slackbot3 months ago

This ticket was mentioned in Slack in #core by drew. View the logs.

comment:7 @DrewAPicture3 months ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to wonderboymusic
  • Status changed from new to reviewing

21848.diff still applies. I could get behind even a partial fix here. @wonderboymusic: can you please commit what you've got so far if you think that's going to work, and either punt the ticket or make a recommendation on fixing what's left?

comment:8 @wonderboymusic3 months ago

In 31958:

When editing an image from the editor, and the image has a value for alignment (but not for width or caption), don't bail without first checking that the alignment's value is not alignnone. If so, add the class to the <a> before bailing.

See #21848.

comment:9 @DrewAPicture3 months ago

  • Keywords dev-feedback added

@wonderboymusic: Following the same procedure in your screencast following [31958] seems to work exactly as before. Should we expect the alignment not to be lost after switching the editor modes?

comment:10 in reply to: ↑ 2 @boonebgorges3 months ago

Replying to ericlewis:

@luffer thanks for the bug report! I can reproduce, but this is trivial.

Maybe we should be trim()ing captions on change in the media modal? Are there use cases where folks want untrimmed captions?

I think it's probably safe to trim(). See 21848.2.diff.

@boonebgorges3 months ago

comment:11 @boonebgorges3 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 32079:

Don't allow whitespace-only image captions from the Media modal.

Captions containing only whitespace trick image_add_caption() into thinking
a caption is required, but the empty caption text confuses wpeditimage into
stripping the 'align' class specified by the user.

Fixes #21848.

Note: See TracTickets for help on using tickets.