Image Browser 2 allows developers to initiate an Image Browser pop-up window and then capture data via JSON when a user selects an image to insert. Integration requires three key parts:

This example module is called my_module.

1. Plug-in function

function my_module_imagebrowserapi($op) {
  switch ($op) {
    case 'load':
      return array(
        'url' => drupal_get_path('module', 'my_module') .'/my_module.js',
      );
      break;
  }
}

2. Javascript file

// $Id$

/**
 * @file my_module.js
 *
 * Javascript plugin for Image Browser.
 *
 * Variables:
 * - data.fid             [File ID]
 * - data.preset          [ImageCache preset name]
 * - data.link_preset     [ImageCache preset name]
 * - data.link_target     [Link target]
 * - data.styles          [CSS classes separated by spaces]
 * - data.filepath        [Filepath to image relative to drupal]
 * - data.image_url       [Full URL to image]
 * - data.link_url        [Full URL to link]
 */

function ib_process_insert(data) {
  // Do whatever I want with the returned JSON data here.
  
  window.close();
}

3. Calling code

Then simply call Image Browser with your module name: <a href="/index.php?q=imagebrowser/my_module">Launch Image Browser</a>