Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#22459 closed defect (bug) (fixed)

Inserting captionless and captioned image together causes shortcode to appear in visual mode

Reported by: trepmal's profile trepmal Owned by: koopersmith's profile koopersmith
Milestone: 3.5 Priority: normal
Severity: normal Version: 3.5
Component: Media Keywords: needs-patch
Focuses: Cc:


  1. select an image with no caption
  2. select an image with a caption
  3. batch-insert into post

The [caption] shortcode will appear in the visual editor.

Change History (4)

#1 @SergeyBiryukov
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#2 @nofearinc
12 years ago

It seems like it's generating the HTML in media-upload.js, around line 368-372, where the code is directly inserted inside of the Visual editor and not evaluated or hidden (and visible only in the Text version).

#3 @koopersmith
12 years ago

  • Keywords needs-patch added

The wpeditimage plugin searches for captions by checking if the inserted string begins with [caption. With multiple images, we're inserting a single string, which is causing the issue here. Instead, we should be inserting multiple strings.

This can be fixed by going into media-upload.js and changing the insert event callback to use each instead of map, and moving the call to insert into the loop.

#4 @koopersmith
12 years ago

  • Owner set to koopersmith
  • Resolution set to fixed
  • Status changed from new to closed

In 22672:

Media: Insert each attachment into the editor individually.

This allows the wpeditimage plugin to correctly identify caption shortcodes.

fixes #22459, see #21390.

Note: See TracTickets for help on using tickets.