TYPO3 ckeditor:允许 img 标签而不启用图像插件

TYPO3 ckeditor: allow img tag without enabling image plugin

在普通的 TYPO3 8 安装中,我希望 ckeditor 允许在源代码中使用 img 标签,而不启用图像插件。 TYPO3中ckeditor的默认配置去掉了图片插件,导致img标签也被去掉了

根据 ckeditor 文档,这可以通过 属性

config.extraAllowedContent = 'img'

但它在我的自定义 yaml 配置中不起作用。当我从源模式切换到所见即所得模式时,img 标签总是条纹状的。

如果我启用图片插件,img 标签会保留。但我不想将此按钮作为选项提供给编辑。

我做错了什么?

这是我的测试 yaml 配置。底部是 extraAllowedContent 选项

imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml" }
editor:
  config:
    contentsCss: ["EXT:rte_ckeditor/Resources/Public/Css/contents.css", "EXT:tucmmforumhook/Resources/Public/Styles/Tucmain.css"]
    stylesSet:
      - { name: "XYZ Text", element: "span", attributes: { class: "highlighted red"} }
      - { name: "Button", element: "a", attributes: { class: "button"} }
      - { name: "Checklist", element: "ul", attributes: { class: "check-list"} }
    format_tags: "p;h2;h3;h4;h5"
    toolbarGroups:
      - { name: styles, groups: [ styles, format ] }
      - { name: basicstyles, groups: [ basicstyles ] }
      - { name: paragraph, groups: [ list, indent, blocks, align ] }
      - { name: links, groups: [ links ] }
      - { name: clipboard, groups: [ clipboard, cleanup, undo ] }
      - { name: editing, groups: [ spellchecker ] }
      - { name: insert, groups: [ insert ] }
      - { name: tools, groups: [ table, specialchar ] }
      - { name: document, groups: [ mode ] }
    justifyClasses:
      - text-left
      - text-center
      - text-right
      - text-justify
    extraPlugins:
      - justify
    removePlugins:
      - image
    removeButtons:
      - Strike
      - Anchor
      - Outdent
      - Indent
      - Blockquote
      - JustifyBlock

    extraAllowedContent:
      - img

为了实现这个你需要切换到AFC的自定义模式: https://sdk.ckeditor.com/samples/acfcustom.html

使用:

allowedContent: 
- img[!src,alt,width,height]

允许图像。 这可能比使 configuration/filtering 适合您的预设更棘手:您还必须将其他允许的标签添加到 allowedContentlist,否则表格、列表等的按钮将不会呈现。

避免使用

allowedContent: true
,因为它会允许一切!

根据@ikon 的回答,我设法使 extraAllowedContent 起作用。而不是

extraAllowedContent:
  - img

够用了

extraAllowedContent:
  - img[!src,alt,width,height]

这使 img 标签保持完整,不需要图像插件