Index: imce.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imce/imce.module,v
retrieving revision 1.8.2.33
diff -u -p -r1.8.2.33 imce.module
--- imce.module	19 Jul 2008 12:51:36 -0000	1.8.2.33
+++ imce.module	1 Dec 2008 18:07:33 -0000
@@ -893,4 +893,33 @@ function imce_integrate($e, $check=NULL)
     drupal_add_js('var imceBrowserURL = "'.url('imce/browse').'";', 'inline');
     $state[$e] = TRUE;
   }
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_wysiwyg_plugin().
+ */
+function imce_wysiwyg_plugin($editor) {
+  static $integrated;
+  switch ($editor) {
+    case 'tinymce':
+      if (!user_access('access imce')) {
+        return;
+      }
+      if (!isset($integrated)) {
+        $integrated = TRUE;
+        drupal_add_js(array('imce' => array('url' => url('imce/browse'), 'wysiwyg_module' => true)), 'setting');
+        drupal_add_js(drupal_get_path('module', 'imce') .'/imce_set_tinymce.js');
+      }
+      return array(
+        'imce' => array(
+          'extensions' => array('imce' => t('IMCE')),
+          'url' => 'http://drupal.org/project/imce',
+          'options' => array(
+            'file_browser_callback' => 'imceImageBrowser',
+            'inline_styles' => TRUE,
+          ),
+          'load' => FALSE,
+        ),
+      );
+  }
+}
Index: imce_set_tinymce.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imce/Attic/imce_set_tinymce.js,v
retrieving revision 1.1.2.6
diff -u -p -r1.1.2.6 imce_set_tinymce.js
--- imce_set_tinymce.js	31 Mar 2008 13:28:19 -0000	1.1.2.6
+++ imce_set_tinymce.js	1 Dec 2008 17:56:30 -0000
@@ -19,11 +19,24 @@ function imceImageBrowser(field_name, ur
   //if (type!='image') return;//work for only images
   var width = 640;
   var height = 480;
-  window.open(imceBrowserURL||'/?q=imce/browse', '', 'width='+ width +', height='+ height +', resizable=1').focus();
+  if (typeof imceBrowserURL != 'undefined') {
+    browserUrl = imceBrowserURL;
+  }
+  else if (typeof Drupal.settings.imce != 'undefined') {
+    browserUrl = Drupal.settings.imce.url;
+  }
+  else {
+    browserUrl = '/?q=imce/browse';
+  }
+  window.open(browserUrl, '', 'width='+ width +', height='+ height +', resizable=1').focus();
   imceTinyWin = win;
   imceTinyField = win.document.forms[0].elements[field_name];
   imceTinyType = type;
   imceTinyURL = url;
 }
 
-$(document).ready(imceInitiateTinyMCE);
+$(document).ready(function() {
+  if (typeof Drupal.settings.imce == 'undefined' || !Drupal.settings.imce.wysiwyg_module) {
+    imceInitiateTinyMCE();
+  }
+});
\ No newline at end of file
