Make WordPress Core

Opened 8 years ago

Closed 4 years ago

#35638 closed defect (bug) (worksforme)

Cutting and pasting an image with a caption within the same post will result in loss of caption.

Reported by: rothschild86's profile rothschild86 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4.1
Component: TinyMCE Keywords:
Focuses: Cc:


As title says. Applies to the rich editor.

The caption should persist through the copy and paste.

Change History (7)

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.

7 years ago

#2 follow-up: @rianrietveld
7 years ago

To kick some life in this ticket:
If you add an image with a caption to the content in visual mode and copy/paste it to another spot in the content, the caption text is copied but no longer inside the caption shortcode and associated with the image.
See for YouTube demo:

Is this a bug or just not possible cc @azaozz / @iseulde

#3 in reply to: ↑ 2 @azaozz
7 years ago

  • Component changed from Editor to TinyMCE
  • Milestone changed from Awaiting Review to 4.8

Replying to rianrietveld:

It's (mostly) a bug :)

The problem is that the "wrapper tag" for the image with caption has to be selected and copied. Then it will retain the caption. Same for dragging it to the desired place inside the editor.

There is a workaround: click on the image, then look at the bottom of the editor at the "element path" (to see it you need to open the second toolbar row). It should look like:

div » dl » dt » img

Clicking on the div will select everything. Then copy and paste.

Can try to improve this. If it is non-editable, clicking on the image should select the wrapper tags too.

#4 @rianrietveld
7 years ago

Thanks @azaozz Tried the workaround and that works perfectly.

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

6 years ago

#6 @flixos90
6 years ago

  • Milestone changed from 4.8 to Future Release

#7 @azaozz
4 years ago

  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Don't see a straightforward way to fix this. Trying to (artificially) extend the selection to include the wrapper element results in other bugs, for example not being able to edit the caption text. It's not possible to extend the selection on copy or drag, too late. The only way I see would be to leave a "placeholder" in the old location of the image after copying or dragging, then let the user paste or finish dragging and drop the image, and then to delete the content that was pasted or dropped and select and move the actual image together with the caption. Unfortunately that is pretty buggy too.

Seems the best way is to make sure the wrapper div is selected before copying, as mentioned above.

Closing as worksforme as there is a workaround. Feel free to reopen with other ideas about how to make this better.

Note: See TracTickets for help on using tickets.