Index: imceimage.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imceimage/imceimage.module,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 imceimage.module
--- imceimage.module	27 Mar 2009 17:30:14 -0000	1.1.2.4
+++ imceimage.module	16 Jun 2009 02:17:16 -0000
@@ -477,25 +477,43 @@ function imceimage_process($element, $ed
   $field = $form['#field_info'][$element['#field_name']];
   $delta = $element['#delta'];
 
-  $link = url('imce/browse');
+  $imce_path = url('imce/browse');
   $field_id = $field['field_name'];
 
   if (trim($element['#value']['imceimage_path']) != '') {
-    $links = t('Change Image') . '</a>]'
-           .'[<a class="imceimage-remove" href="javascript:'
-           . "imceImage.remove('$delta-$field_id')"
-           . '">' . t('Remove') . '</a>]';
-  } 
-  else {
-    $links = t('Add Image') . '</a>]';
+    $links = array( 'open' => t('Change Image'),
+                    'remove' => t('Remove'),
+             );
+  } else {
+    $links = array( 'open' => t('Add Image') );
   }
 
+  unset($html);
+
+  foreach ($links as $action => $text) {
+    if (file_exists( $filename = drupal_get_path('module', 'imceimage') . "/$action-image.png")) {
+      $filename = base_path() . $filename;
+      $link_content = "<img src='$filename' alt='$text' />";
+    } else {
+      $link_content = $text;
+    }
+    
+    $js_arg = "\"$delta-$field_id\"";
+    $js_arg = $action == 'open' ? "\"$imce_path\"," . $js_arg : $js_arg;
+    
+    $html .= "<a class='imceimage-$action' alt='$text' href='javascript:imceImage.$action($js_arg)'>$link_content</a>";
+  
+  }
+
+
+  $label = '<label>' . check_plain($field['widget']['label']) . '</label>';
+
   $element['imce_add'] = array(
     '#type' => 'item',
-    '#value' => $field['widget']['label'] 
-               .' [<a href="'
-               ."javascript:imceImage.open('$link', '$delta-$field_id')"
-               .'" class="imceimage-add">'. $links );
+    '#title' => $label,
+    '#value' => $html,
+    '#description' => $field['widget']['description'],
+    );
 
 
   $element['imceimage_path'] = array(
@@ -515,7 +533,14 @@ function imceimage_process($element, $ed
     '#id' => "imceimageheight-$delta-$field_id",
     '#default_value' => $element['#value']['imceimage_height'],
   );
-
+  $element['imce_view'] = array(
+    '#type' => 'item',
+    '#value' => theme_imceimage_image($element['#value']['imceimage_path'],
+                            $element['#value']['imceimage_width'],
+                            $element['#value']['imceimage_height'],
+                            $element['#value']['imceimage_alt'], 
+                            "imceimagearea-$delta-$field_id")
+  );
   $element['imceimage_alt'] = array(
     '#type' => 'textarea',
     '#id' => "imceimagealt-$delta-$field_id",
@@ -529,15 +554,6 @@ function imceimage_process($element, $ed
     '#description' => t('The caption text for this image.'), //$element['#description']['imceimage_alt'],
   );
 
-  $element['imce_view'] = array(
-    '#type' => 'item',
-    '#value' => theme_imceimage_image($element['#value']['imceimage_path'],
-                            $element['#value']['imceimage_width'],
-                            $element['#value']['imceimage_height'],
-                            $element['#value']['imceimage_alt'], 
-                            "imceimagearea-$delta-$field_id")
-  );
-
 
   return $element;
 }
