Support » Plugins » Hacks » AJAX search for adding links/media

  • Resolved Doodlebee

    (@doodlebee)



    Hello all 🙂

    I’m trying to figure out what WordPress is using in the admin area for the AJAX stuff: a) when you click the “media” button the popup window shows , and b) within the window, you can start typing the name of the image you want, and via AJAX, it’ll show results as you type.

    I’m curious as to what two functions pull this off?

    I’m working on a plugin where I need to have a popup window with AJAX search, and instead of using some external stuff (since this is inly happening with the admin area), I just wanted to hijack what WordPress uses to pull this off, and tie into it for the plugin I’m writing.

    I’ve been searching like crazy for the info, but so far I’m coming up empty. Can anyone point me in the right direction?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The media picker interface and functionality is built as a set of Backbone Models, States, and Views. It is pretty complex, but if you try hard enough you can definitely decipher it.

    Thanks. Actually, I’m just curious as to what function (or set of functions, initially) that pull it in. I can’t seem to sort out how they are getting pulled in. once I know that, I can get it going – but I can’t even seem to find what function is pulling in the scripts that accomplish it. Thanks, though! I guess I’ll keep slugging through and find it on my own.

    ETA: I believe I’ve found it. in case anyone else is looking for the same starting point: the function is “wp_enqueue_media“, located in includes/media.php. The script to look at is in includes/js/media-views.js. Hope that helps someone else.

    For the record, I found a few other good tidbits of info regarding this, in case anyone else needs help:

    Using the WordPress 3.5 Media Uploader within plugins

    Display Media Uploader in Own Plugin on WordPress 3.5

    These got me off on a pretty good start.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘AJAX search for adding links/media’ is closed to new replies.