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

时间:2018-03-22 06:59:26

标签: ckeditor typo3

在普通的TYPO3 8安装中,我希望ckeditor允许源代码中的img标记,而不启用图像插件。 TYPO3中ckeditor的默认配置会删除图像插件,这也会导致img标记被删除。

根据ckeditor文档,可以使用属性

来实现
config.extraAllowedContent = 'img'

但它在我的自定义yaml配置中不起作用。当我从源码切换到wysiwyg模式时,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

2 个答案:

答案 0 :(得分:2)

根据@ikon的回答,我设法让extraAllowedContent工作。而不是

extraAllowedContent:
  - img

这足以使用

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

这样可以保持img标签的完整性,而无需图像插件

答案 1 :(得分:0)

为了实现这一目标,您需要切换到AFC的自定义模式: https://sdk.ckeditor.com/samples/acfcustom.html

使用:

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

允许图像。 使配置/过滤适合您的预设可能很棘手:您还必须将其他允许的标签添加到allowedContent列表中,否则不会呈现表格,列表等按钮。

避免使用

allowedContent: true
因为它会允许所有内容!