Created
November 22, 2013 00:37
-
-
Save simshaun/7592631 to your computer and use it in GitHub Desktop.
TinyMCE 4.0.11 - Automatically remove width and height attributes from img elements inserted via the img plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup: function (editor) { | |
editor.on('init', function(args) { | |
editor = args.target; | |
editor.on('NodeChange', function(e) { | |
if (e && e.element.nodeName.toLowerCase() == 'img') { | |
tinyMCE.DOM.setAttribs(e.element, {'width': null, 'height': null}); | |
} | |
}); | |
} | |
} |
Great snippet, I tried adding the widht and height as css, it worked in my environment. :)
setup: function (editor) {
editor.on('init', function(args) {
editor = args.target;
editor.on('NodeChange', function(e) {
if (e && e.element.nodeName.toLowerCase() == 'img') {
width = e.element.width;
height = e.element.height;
tinyMCE.DOM.setAttribs(e.element, {'width': null, 'height': null});
tinyMCE.DOM.setAttribs(e.element,
{'style': 'width:' + width + 'px; height:' + height + 'px;'});
}
});
});
}
This code blocks all functionality. There is a configuration option to disable the image dimension input fields in the image modal. Now resizing images from the editor is still possible.
Source: http://www.tinymce.com/wiki.php/Configuration:image_dimensions
Guys i load an HTML in tinymce 4 and i successfully integrate https://github.com/vikdiesel/justboil.me plugin with tinymce. My html has many divs i want to the picture exactly as the size of div. can you guys help me about it..?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great snipptet! Thx. There is missing a "});" around line 9.