tinyMCE callback handler on image drag&drop


tinyMCE supports dragging images from a website (not local file browser) to the rich text editor field. They get converted to and <img src=''>...</img> tag and are immediately displayed as images.

I would like to change the src url of the image tag when it is inserted that way. I tried using the urlconverter_callback handler and the paste_preprocess handler from the paste plugin but neither of them get triggered when I drop the image to the editor field.

Which callback can I use to react on an image drag&drop to the editor? Or is there another way to change the image src when it's dropped?

(urlconverter_callback works when I add the image with the 'Insert Image' button but that's not what I'm looking for.)


The key relies on what's already told: Drag-n-Drop events belong to the browser domain, so TinyMCE knows nothing about them unless we bind them, which in this case it's not necessary.

It's also important to have in mind the way Drag-n-Drop interactions share information between the different events: reading and writting the <strong>dataTransfer</strong> property via <strong>getData</strong> and <strong>setData</strong> functions.

That said, this is my aproach (note I'm using jquery for selection and event binding):

Bind the <strong>dragstart</strong> event to the image, so it fires when we start the interaction. Make the string replacement and store the result on dataTransfer.

<a href="https://gist.github.com/3040473" rel="nofollow">https://gist.github.com/3040473</a>

Useful links:

<ul><li><a href="http://www.useragentman.com/blog/2010/01/10/cross-browser-html5-drag-and-drop/" rel="nofollow">http://www.useragentman.com/blog/2010/01/10/cross-browser-html5-drag-and-drop/</a></li> <li><a href="https://developer.mozilla.org/En/DragDrop/Drag_and_Drop" rel="nofollow">https://developer.mozilla.org/En/DragDrop/Drag_and_Drop</a></li> </ul>


  • Which way to go with graphic-intense multi-touch app, XNA or WPF?
  • JQuery UI selectable plugin - Multiple mouse drag selection and unselect option
  • Change color of row programmatically in WatchKit
  • Can't CTRL+Drag NSButton to custom NSView header
  • onActivityResult() not called after startActivityForResult() with Intent.ACTION_GET_CONTENT
  • React Native fetch is not a function
  • jquery draggable stop event
  • Webpack-dev-server and isomorphic react-node application
  • WPF Animation doesn't run first time
  • Missing permission to control media error on Android 5/L
  • Updates to SolrConfig.xml file are not being reflected
  • Print: Entry, “:CFBundleIdentifier”, Does Not Exist have tried most solutions
  • How to capture enclosing scope in Runnable
  • Unmarshalling unknown type code exception while resuming
  • React Router and Arbitrary Query Params: Page Refreshes Unintentionally on Load?
  • IE11 textarea loses focus if another textarea is disabled
  • Zend framework 2 : Add different authentication adapter for two different modules
  • Layout design help Android
  • setContentView() is not enough to switch between layouts?
  • Client side validation mvc dropdown
  • Creating a C++ function that calls other Lua function
  • pythonanywhere - How do I use websockets to transmit messages as per the web2py messaging example?
  • what is the purpose of “export as namespace foo”?
  • Pre-populated SQLite Database not reading properly in Android Studio
  • Deploying a CodeRush plugin from the Community Site
  • Android onKey w/ virtual keyboard
  • How can we prepend rows to a react native list-view?
  • How to override value that appears in a dropdown in the rails_admin gem
  • Defined variables not working in javascript files when I use getScript
  • Can't remove headers after they are sent
  • How to synchronize jQuery dialog box to act like alert() of Javascript
  • Why cepheus don't send int without quotes to orion?
  • Detect when Facebook like button is clicked
  • AJAX Html Editor Extender upload image appearing blank
  • Can I have the cursor start on a particular column by default in jqgrid's edit mode?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Circular dependency while pushing http interceptor
  • Linker errors when using intrinsic function via function pointer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`