wysihtml5 - Attributes are removed in HTML code -
i use wysihtml5. when insert image
<img alt src="src" media_img_id="123" data-title="title" data-author="author" />
the result is
<img alt src="src" />
rules img
"img": { "remove": 0, "check_attributes": { "width": "numbers", "alt": "alt", "src": "url", // if compiled master manually change 'url' 'src' "height": "numbers", "media_img_id": "numbers" }, "add_class": { "align": "align_img" } },
how make attributes not removed?
i have same task today extend abilities of editor. should add attributes in special object: i'm using additionaly bootstrap3-wysihtml5 - https://github.com/schnawel007/bootstrap3-wysihtml5 . object should added new attributes element:
var defaultoptions = $.fn.wysihtml5.defaultoptions = { /../ "img": { "check_attributes": { "width": "numbers", "alt": "alt", "data-encid": "alt", <<-here custom attribute "src": "url", "height": "numbers" } }, /../ }
and in wysihtml5.js should add condition in src attribute differs classical source (that plugin expected) "http://example.png".
line 4922:
if (checkattributes) { (attributename in checkattributes) { method = attributecheckmethods[checkattributes[attributename]]; if (!method) { continue; } newattributevalue = method(_getattribute(oldnode, attributename)); if (typeof(newattributevalue) === "string") { attributes[attributename] = newattributevalue; } } }
replace with:
if (checkattributes) { (attributename in checkattributes) { method = attributecheckmethods[checkattributes[attributename]]; if (!method) { continue; } newattributevalue = (attributename == "src" && checkattributes["data-encid"]) ? oldnode.src : method(_getattribute(oldnode, attributename)); if (typeof(newattributevalue) === "string") { attributes[attributename] = newattributevalue; } } }
here copy src attribute value without checking through wysihtml5.js core.
hope helps!
Comments
Post a Comment