WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 3.5 image insert fails with "send_to_editor is not a function" - FIXED (2 posts)

  1. annotum
    Member
    Posted 1 year ago #

    I was seeing an issue in my custom theme upload code where I could not insert images.

    Steps to reproduce:

    1. Click insert image button on toolbar
    2. Select, upload image
    3. Enter details in custom dialog, click "insert" button, which calls send_t0_editor.

    Expected

    Image inserted in article editor

    Actual

    Nothing happens. Javascript console in Chrome/FF reports "send_to_editor is not a function" or "Uncaught TypeError: Object [object Window] has no method 'send_to_editor'"

    This error occurs because prior to 3.5 the media-upload script (which contains send_to_editor always gets loaded; in 3.5, it is only loaded in some cases. The fix is to invoke wp_enqueue_script in my theme's functions.php in order to load the media-upload script every time:

    wp_enqueue_script( 'media-upload' );

    I'm posting this in case someone else sees the same issue, so they can find this solution via search.

    Here's the fix on Github:

    https://github.com/Annotum/Annotum/commit/ce1180c63725c11c47a459c27aad5629caf18df7

  2. markpanado
    Member
    Posted 11 months ago #

    This helps me solve my problem at my site's built-in gallery http://www.vicelv.ph ! Thank you :)

Topic Closed

This topic has been closed to new replies.

About this Topic