See this page for IMCE 6.x integration API

IMCE introduces two javascript hooks for custom usage. One of them is hookImceFinish function and the other is global hookImceUrl variable. In order to use these hooks one must open IMCE browser by specifying a proper window name with window.open method. That window name plus hook names will be the custom function and the custom URL.

Here is a sample code for opening IMCE with window.open:

window.open('imce/browse', 'windowName', 'width=640, height=480');

For this instance of imce there should be a previously declared function named as windowNameImceFinish and optionally a variable named as windowNameImceUrl. If the function exists, IMCE will call it when the user clicks "add" link. windowNameImceUrl will be used for highlighting if it matches any url in the file list.

hookImceFinish

This function is called with five parameters:

  1. file path - URL of the selected file in the file list
  2. image width - width of the selected image. (0 if it's not an image)
  3. image height - height of the selected image.
  4. file size - formatted file size (ex: 35.2 KB, 45 bytes, etc).
  5. IMCE window - reference to the currently active IMCE window. it can be used for closing the pop-up.

so, one can implement a function like this:

function windowNameImceFinish(path, w, h, s, imceWin) {
  imceWin.close();
  alert('selected file path='+ path +', width='+ w +', height='+ h +', filesize='+s);
}

hookImceUrl

This optional global variable is used for highlighting of the matching url in the file list. In other words, if it's value matches any of the paths in the list, that file is highlighted.

One may change the value of this variable just before opening the IMCE pop-up.

windowNameImceUrl = '/files/images/img.gif';