Image Widget
possible clashes with other plugins/copies - send_to_editor (3 posts)

  1. rcain
    Posted 5 years ago #


    Firstly, great plugin. Thanks. Helped me get my head around image upload stuff.

    One problem I noticed, when creating a duplicate (heavily renamed) plugin in order to extend your functionality a little, is that the way you are declaring javascript function send_to_editor, can cause clashes and bad behaviour.

    the solution I found is quite simple and as follows:

    in file image-widget.js:

    line 5ish:
    function: send_to_editor
    change from: function send_to_editor(...
    change to (eg): functon my_packagename_send_to_editor(...

    line 92-95ish:
    change from: `...
    if (jQuery(event.target).is('a.thickbox-image-widget')) {
    tb_show("Add an Image", event.target.href, false);

    change to (eg): `...
    if (jQuery(event.target).is('a.thickbox-image-widget')) {
    tb_show("Add an Image", event.target.href, false);

    there is some further info about this general issue to be found at eg:




    hope this helps someone. possibly role something like this into next release?


  2. rcain
    Posted 5 years ago #


    further down the line, i find that the above solution doesn't quite work.

    i think the problem lies in the fact that the original image widget JS code redefines (replaces) the standard wp send_to_editor function BUT does not restore it once it has has finished (running the click to upload event).

    not such a problem if there are no other widgets using similar technique, but serious breakages if there are (as in my case).

    indeed, having backed out all my changes, reverting to the kosha version of the plugin + deactivated all my oher widget plugins, i get the following strange behaviour, intermittently:

    when selecting admin, appearance, widgets from the lhs menu, all widget sidebar areas (rhs of the screen), underneath the one containing the image widget, sometimes disappear! at the same time, none of the widgets anywhere on the page respond to click (open) or drag-n-drop. its as if the JS/JQuery is completely missing/broken. refreshing the browser whilst still on the widgets admin page sometimes make them appear again, and all behave properly.

    As i add back more widget plugins the situation changes slightly, in that refreshing the browser (whilst on the widgets admin page), has the effect of toggling the error on and off - ie. refresh breaks it, refresh again, and everything works again, etc, etc.

    invocation of the problem also seems slightly random (sometimes the widget admin screen behaves fine then, suddenly will break again as described above.)

    just to complicate matters further, i have come across many reports of the core wp widget admin page breaking in a similar (though not identical) way, all on its own.

    i'm about to try some further code changes (to restore original send_to_editor js funcs as i just suggested) and will report back any improved results.

    it does seem however, there are some problems need addressing here in image-widget.js.

    can anyone replicate these symptoms? fix them?

    any feedback appreciated.

  3. Peter Chester
    Modern Tribe
    Plugin Author

    Posted 5 years ago #

    I think the widget area crashing you're describing is due to a general js conflict. I doubt that's related to this plugin. All the same your conflict solution is great! I just added it and deployed! Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Image Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic