WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 18 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 19 months ago.
21848.2.diff (839 bytes) - added by boonebgorges 18 months ago.

Download all attachments as: .zip

Change History (13)

#2 follow-up: @ericlewis
2 years 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?

#3 @wonderboymusic
19 months ago

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

#4 @wonderboymusic
19 months ago

21848.diff fixes part of this.

#5 @samuelsidler
18 months ago

  • Priority changed from normal to low

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


18 months ago

#7 @DrewAPicture
18 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?

#8 @wonderboymusic
18 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.

#9 @DrewAPicture
18 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?

#10 in reply to: ↑ 2 @boonebgorges
18 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.

#11 @boonebgorges
18 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.