tinymce.create("tinymce.plugins.wpEditImage",{url:"",editor:{},init:function(e,t){var n=this,d={};n.url=t,n.editor=e,n._createButtons(),e.addCommand("WP_EditImage",n._editImage),e.onInit.add(function(i){i.dom.events.add(i.getBody(),"mousedown",function(e){var t;"IMG"==e.target.nodeName&&(t=i.dom.getParent(e.target,"div.mceTemp"))&&(tinymce.isGecko?i.selection.select(t):tinymce.isWebKit&&i.dom.events.prevent(e))}),i.dom.events.add(i.getBody(),"keydown",function(e){var t,n;if(13==e.keyCode&&(t=i.selection.getNode(),n=(t=i.dom.getParent(t,"dl.wp-caption"))?i.dom.getParent(t,"div.mceTemp"):n))return i.dom.events.cancel(e),e=i.dom.create("p",{},"\ufeff"),i.dom.insertAfter(e,n),i.selection.setCursorLocation(e,0),!1}),"ontouchstart"in window&&i.dom.events.add(i.getBody(),"touchstart",function(e){n._showButtons(e)})}),e.onMouseUp.add(function(n,e){var i;tinymce.isWebKit||tinymce.isOpera||(!d.x||e.clientX==d.x&&e.clientY==d.y||"IMG"==(i=n.selection.getNode()).nodeName&&window.setTimeout(function(){var e,t=n.dom.getParent(i,"dl.wp-caption");i.width==d.img_w&&i.height==d.img_h||(i.className=i.className.replace(/size-[^ "']+/,"")),t&&(e=n.dom.getAttrib(i,"width")||i.width,e=parseInt(e,10),n.dom.setStyle(t,"width",10+e),n.execCommand("mceRepaint"))},100),d={})}),e.onMouseDown.add(function(e,t){n._showButtons(t)}),e.onBeforeSetContent.add(function(e,t){t.content=e.wpSetImgCaption(t.content)}),e.onPostProcess.add(function(e,t){t.get&&(t.content=e.wpGetImgCaption(t.content))}),e.wpSetImgCaption=function(e){return n._do_shcode(e)},e.wpGetImgCaption=function(e){return n._get_shcode(e)},e.onBeforeExecCommand.add(function(e,t,n,i){var d;"mceInsertContent"==t&&(d=e.dom.getParent(e.selection.getNode(),"div.mceTemp"))&&(t=e.dom.create("p"),e.dom.insertAfter(t,d),e.selection.setCursorLocation(t,0))})},_do_shcode:function(e){return e.replace(/(?:
)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g,function(e,t,n){var i,d,o,a,c=tinymce.trim,r=t.match(/id=['"]([^'"]*)['"] ?/);return(d=(t=(i=(t=r?t.replace(r[0],""):t).match(/align=['"]([^'"]*)['"] ?/))?t.replace(i[0],""):t).match(/width=['"]([0-9]*)['"] ?/))&&(t=t.replace(d[0],"")),a=(a=(n=c(n)).match(/((?:]+>)? [\s\S]*<\/p>)?[\s\S]*/gi," $1]+>(?:<\/a>)?)([\s\S]*)/i))&&a[2]?(o=c(a[2]),c(a[1])):(o=c(t).replace(/caption=['"]/,"").replace(/['"]$/,""),n),r=r&&r[1]?r[1]:"",i=i&&i[1]?i[1]:"alignnone",(d=d&&d[1]?d[1]:"")&&o?(t="mceTemp","aligncenter"==i&&(t+=" mceIEcenter"),'
]+)>\s*
"))+"[/caption]":n});return n=0!==n.indexOf("[caption")?t.replace(/[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(