Image Browser 2 API
Last updated on
30 April 2025
You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules
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>
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion