Other

Tiny MCE ImageManager. Insert Uploaded Images Automatically

Imagen 1

I am talking about:

Uploading and inserting images using ImageManager (TinyMCE plugin) in 3 clicks, instead of 4 and without search for your uploaded images inside the image file list. Images will be inserted in tinyMCE’s textarea automatically.

Ninja solution:

line 528: imagemanager-path/pages/im/js/imagemanager.js . Look for “onupload : function(){”

onupload : function(e) {
//Imagemanager.listFiles();
 if (e.files.length > 0 ){
  var s = t.currentWin.getArgs();selectedPaths=[];
  $(e.files).each(function(i, v) {
    selectedPaths.push(v.path); });
  RPC.insertFiles({
    relative_urls : s.relative_urls,
    document_base_url : s.document_base_url,
    default_base_url : s.default_base_url,
    no_host : s.remove_script_host || s.no_host,
    paths : selectedPaths,
    progress_message : $.translate("{#common.image_data}"),
    insert_filter : s.insert_filter,
    oninsert : function(o) {
      if (s.oninsert) {
        $(o.files).each(function(i, v) {
                t.focusedFile = v; o.focusedFile = v; s.oninsert(o);
        });
      }
        t.currentWin.close();
      }
  }); // end RPC.exec
} // end if
} // end onupload

 

Note: function(e){
Paste this code inside your onupload:function(){
That’s it.

Problems of this solution
– It’s not a plugin, so if you update your imagemanger, you will have to make this change again.
– If you don’t allow overwrite files, if you try to upload a file that is allready uploaded, this file won’t be uploaded neither inserted in tinymce’s textarea.
– Not tested on IE, just chrome,safari and firefox.

Two days ago, I would payed for this code. I Hope this will be usefull for you.

Beto López
Software engineer & Full stack website developer who has left a startup job where wednesdays were "yoga days", to build an standarized-low-cost technical support service, deepest than than the service hosting companies provide, for website owners, freelancers and digital businesses. Personal Website, Linkedin y Twitter.


Tiny MCE ImageManager. Insert Uploaded Images Automatically
We are always online, we reply fast
Get in touch
Php Ninja