typo3ckeditortypo3-11.x

Allow figcaption within TYPO3 editor?


I am using TYPO3 11 and the text editor is the default CKEditor 4.

In order to get image captions within the text editor I have added the 'Enhanced Image Plugin' to the CKEditor:

myeditor.yaml:

editor:
  config:
    extraPlugins:
      - image2

    externalPlugins:
      image2:
        resource: "EXT:myext/Resources/Public/CKeditor/Plugins/image2/"

This works as expected in the editor, the editor source looks like:

<figure class="image">
<img alt="" height="200" src="/fileadmin/images/image.png" width="200" />
<figcaption>Caption</figcaption>
</figure>

But the content rendered to the page renders the figcaption as escaped HTML:

<figure class="image">
<p><img alt="" height="200" src="/fileadmin/images/logo.png" width="200"> &lt;figcaption&gt;Caption&lt;/figcaption&gt; </p>
</figure>

How can I fix this?


Solution

  • I found that the problem comes from Fluid's format.html.

    The behaviour of it can be modifed for the RTE using typoscript:

    lib.parseFunc_RTE {
        
        #This line will enable figcaption to render as a tag:
        externalBlocks := addToList(figcaption)
    
        #This line prevents unwanted p tags being inserted in the figure tag
        externalBlocks.figure.callRecursive >
    
    }