php – CKEditor对齐图像而不是浮动
发布时间:2020-12-13 18:04:54 所属栏目:PHP教程 来源:网络整理
导读:所有, 我在我的应用程序中非常成功地使用CKEditor,允许客户端构建和发送HTML电子邮件.只有一个障碍–CK使用style =“float:left”用于图像,而Outlook拒绝接受它是有效的(方式去,微软..)FCKEditor曾经使用对齐而不是浮点来定位图像.有没有办法破解CKEditor在
所有,
我在我的应用程序中非常成功地使用CKEditor,允许客户端构建和发送HTML电子邮件.只有一个障碍–CK使用style =“float:left”用于图像,而Outlook拒绝接受它是有效的(方式去,微软..)FCKEditor曾经使用对齐而不是浮点来定位图像.有没有办法破解CKEditor在图像对齐方面的行为? 在CK的论坛上发帖是徒劳的.任何帮助表示赞赏!
这是另一种选择……我发现宽度/高度刚刚改变以添加对齐.
CKEDITOR.on('instanceReady',function (ev) { // Ends self closing tags the HTML4 way,like <br>. ev.editor.dataProcessor.htmlFilter.addRules( { elements: { $: function (element) { // Output dimensions of images as width and height if (element.name == 'img') { var style = element.attributes.style; if (style) { // Get the width from the style. var match = /(?:^|s)widths*:s*(d+)px/i.exec(style),width = match && match[1]; // Get the height from the style. match = /(?:^|s)heights*:s*(d+)px/i.exec(style); var height = match && match[1]; // Get the align from the style var match = /(?:^|s)floats*:s*(left|right)/i.exec(style),align = match && match[1]; if (width) { element.attributes.style = element.attributes.style.replace(/(?:^|s)widths*:s*(d+)px;?/i,''); element.attributes.width = width; } if (height) { element.attributes.style = element.attributes.style.replace(/(?:^|s)heights*:s*(d+)px;?/i,''); element.attributes.height = height; } if (align) { element.attributes.style = element.attributes.style.replace(/(?:^|s)floats*:s*(left|right);?/i,''); element.attributes.align = align; } } } if (!element.attributes.style) delete element.attributes.style; return element; } } }); }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |