TYPO3 ckeditor:允许img标签而不启用图像插件 [英] TYPO3 ckeditor: allow img tag without enabling image plugin
问题描述
在普通的TYPO3 8安装上,我希望ckeditor允许源中的img标签,而不启用图像插件。 TYPO3中ckeditor的默认配置会删除图像插件,这也会导致img标签也被删除。
On a plain TYPO3 8 installation, I want ckeditor to allow the img tag in the source, without enabling the image plugin. The default configuration of ckeditor in TYPO3 removes the image plugin, which causes img tags to be removed as well.
根据ckeditor文档,可以使用属性来实现
According to the ckeditor documentation, this can be achieved with the property
config.extraAllowedContent = 'img'
,但在我的自定义yaml配置中不起作用。当我从源模式切换到所见即所得模式时,img标签总是被剥夺。
but it does not work in my custom yaml configuration. img tags are always striped when I switch from source to wysiwyg mode.
如果启用了图像插件,则会保留img标签。但是我不想让编辑者将此按钮作为选项。
If I enable the image plugin, img tags are kept. But I do not want to give to the editors this button as an option.
我在做什么错了?
这是我的测试Yaml配置。底部是extraAllowedContent选项
Here is my test yaml configuration. At the bottom is the extraAllowedContent option
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
推荐答案
基于@ikon的答案,我设法使extraAllowedContent起作用。代替
Based on @ikon answer, I managed to make the extraAllowedContent to work. Instead of
extraAllowedContent:
- img
足够使用
extraAllowedContent:
- img[!src,alt,width,height]
这可以使img标签保持完整,而无需图像插件
This keeps the img tags intact, without needing the image plugin
这篇关于TYPO3 ckeditor:允许img标签而不启用图像插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!