Last week, I shared a short post on how to include your own instance of the WordPress Media Uploader in your theme or your plugin.

Though it walks you through everything that you need, on aspect of using the instance that I described is that it’s limited. This is fine for certain situations, but there are other times where you may want to grab more information from the user.

Case in point, the post received the following comment:

Now, how do you activate (turn on) the Insert Image via URL feature of the Media Uploader?

Which I thought was a good question especially given that most of us are used to seeing more options in the media uploader than what the previous post described.

Fields for the WordPress Media Uploader

Since WordPress is using both Backbone and Underscores to drive the user interface and events for the Media Uploader, all that we need to do is to change the way in which we’re initializing the file_frame and to update the event handler for when an image is selected.

Though the code includes plenty of comments that should explain what’s going on, note that the three most important things are:

  1. We’ve specified a `frame` argument
  2. We’ve set the `state` to `insert`
  3. We’ve changed the event handler to `on` for when an image is selected

Other than that, everything is the same.

Can More Be Done?

Yes – because of the nature of the libraries used to build this UI, you can create your own templates for the WordPress media uploader and use the frame argument to retrieve your custom post.

The challenge is that if you’re not familiar with Backbone and Underscores – which I’m not – you have to do a lot of poking around in the core code to see how they’ve implemented it, and then use that as an example.

Even still, the code above offers more information about the selected image than the initial version of the code shared last week.