Redactor image caption not saved and formatting lost In Craft CMS 2.6.2945, I've added the "image" button in the Redactor config.  In the editor, I've added an image and added a caption (by clicking the inserted image).  When the image is saved, the caption shows up properly and I could see that it was set as figure/figcaption tags after inspecting it.

However, after saving the entry (save and continue editing doesn't even work now as it takes you to the Entries page), the formatting gets lost and the image ends up in a p tag, followed by the caption in a p tag in the editor, but in no tags in templates as raw html.

Is anyone using captions and having troubles?

Added the following comment:


  After some more testing and debugging, I'm noticing that Redactor is
  outputting malformed HTML. The img is going in a p tag, following by a
  figcaption tag. Since my rich text field was set up to clean malformed
  HTML, saving the entry would get rid of the orphaned figcaption tag.
  Any ideas why the img is not going in a figure tag?


Edit: here's the JSON:

I also turned off the HTML purify and clean options but that didn't work out.

{
    "buttons": ["format","bold","lists","link","file","image"],
    "plugins":["video","source"],
    "toolbarFixed": true,
    "formatting": ["p", "blockquote", "h2", "h3", "h4", "h5", "h6"],
    "formattingAdd": {
        "para-intro": {
            "title": "Paragraph Intro",
            "args": ["p", "class", "intro", "toggle"]
        },
        "caption": {
            "title": "Caption",
            "args": ["p", "class", "cap"]
        }
    }
}
I copied your Redactor settings to a clean installation of Craft (2.6.2945) and added an image to a Rich Text field set to use those specific settings. Initially I encountered the same behaviour. However, unlike in your experience, after disabling the Purify HTML? option on the Rich Text field, the figcaption element persisted after saves.