--- imce.module.orig	2007-05-14 19:57:39.000000000 +0200
+++ imce.module	2008-07-17 09:24:27.000000000 +0200
@@ -119,7 +119,10 @@ function imce_browse() {
   $syspath = file_directory_path();
   $basepath = base_path();
   $imcepath = $basepath. drupal_get_path('module', 'imce');
-  $header = array(array('data'=>t('filename'), 'class'=>'filename'), array('data'=>t('size'), 'class'=>'size'), array('data'=>t('dimensions'), 'class'=>'dimensions'), array('data'=>t('date'), 'class'=>'date'), array('data'=>t('operations'), 'class'=>'operations'));
+  $header = array(array('data'=>t('filename'), 'class'=>'filename'), 
+	array('data'=>t('size'), 'class'=>'size'), array('data'=>t('dimensions'), 'class'=>'dimensions'), array('data'=>t('date'), 'class'=>'date'), array('data'=>t('operations'), 'class'=>'operations'), 
+	array('data'=>t('thumb'), 'class'=>'thumb'), 
+	);
   $token = drupal_get_token('imce');
 
   //file list
@@ -132,11 +135,20 @@ function imce_browse() {
     drupal_set_message(t('File was deleted due to quota exceed!'), 'error');
   }
   foreach ($directory['files'] as $path=>$file) {
+    $thumb_preset = variable_get('imce_settings_imagecachethumbpreset', '');
+    if(module_exists('imagecache') && !empty($thumb_preset)){
+	$filepath = $set->dir . '/' . $file['f'];
+    	$img = theme('imagecache',$thumb_preset, $filepath , $alt = check_plain($file['f']), $title = check_plain($file['f']), $attributes = NULL);
+    }
+    else
+	$img = "";
+
     $rows[] = array(array('data' => $file['f'], 'class' => 'filename'),
       array('data' => format_size($file['s']), 'class' => 'size', 'id' => 's-'.$file['s']),
       array('data' => $file['w'].'x'.$file['h'], 'class' => 'dimensions'),
       array('data' => date('Y-m-d', $file['d']), 'class' => 'date', 'id' => 'd-'.$file['d'], 'title' => date('H:i:s', $file['d'])),
       array('data' => $set->delete ? l(t('delete'), 'imce/delete/'.$file['f'], NULL, 'token='.$token) : '', 'class' => 'operations'),
+      array('data' => $img, 'class' => 'thumb'),
     );
   }
   if (!isset($rows)) {
@@ -154,7 +166,7 @@ function imce_browse() {
       $foptions = ' <form action="'.url('imce/dir').'" name="dirform" id="dirform" method="post"><select name="dirname" id="dirname">'. ($subdir ? '<option value="..">'. t('Up') .'</option>' : '') .'<option value="/" selected="selected">/</option>'.$foptions.'</select><input type="submit" name="op" id="dirop" value="'.t('Go').'" /><input type="hidden" name="token" value="'. $token .'" /></form>';
     }
   }
-
+  # fix: genera sempre una thumbnail
   //upload form
   if ($set->upload) {
     $uploadform = '<form action="'.url('imce/upload').'" method="post" id="uploadform" enctype="multipart/form-data">
@@ -664,6 +676,12 @@ function imce_form_admin_form() {
     '#maxlength' => 255,
     '#description' => t('This feature allows you to add your images or files as <strong>html code into any plain textarea</strong>. This is useful especially when you dont use a wysiwyg editor such as tinyMCE or FCKeditor. Enter <strong>comma separated textarea IDs</strong> if you want to enable this feature. Otherwise, leave it blank. Hint: ID of Body fields in most node types is edit-body.'),
   );
+  $form['common']['imagecachethumbpreset'] = array('#type' => 'textfield',
+    '#title' => t('ImageCache thumbnails preset name'),
+    '#default_value' => variable_get('imce_settings_imagecachethumbpreset', ''),
+    '#maxlength' => 255,
+    '#description' => t('Enable ImageCache thumbnails on browsing specifying the preset name.'),
+  );
   if (count($roles)>1) {//role precedence settings appear if there is more than 1 role.
     $rids = $rtext = array();
     foreach ($roles as $rid=>$name) {
@@ -709,6 +727,9 @@ function imce_form_admin_form_submit($fo
   if (isset($edit['common']['textarea'])) {
     variable_set('imce_settings_textarea', $edit['common']['textarea']);
   }
+  if (isset($edit['common']['imagecachethumbpreset'])) {
+    variable_set('imce_settings_imagecachethumbpreset', $edit['common']['imagecachethumbpreset']);
+  }
   if (isset($edit['common']['rank'])) {
     variable_set('imce_settings_rank', explode('>', str_replace(' ', '', $edit['common']['rank'])));
   }
