How To insert an image at cursor position in tinymce
From the above mentioned question I manage to add an Image in TinyMCE.
var ed = tinyMCE.get('txt_area_id'); // get editor instance
var range = ed.selection.getRng(); // get range
var newNode = ed.getDoc().createElement ( "img" ); // create img node
newNode.src="sample.jpg"; // add src attribute
range.insertNode(newNode); // insert Node
I am trying to add the width to newNode
with this code:
newNode.style = "width:600px;"; // not working
but its not working, same goes for class I cannot add a class via this code:
newNode.class= "myClass"; // this one is also not working
If any one have some idea please let me know thanks.