--- privatemsg.module.bak	2008-09-01 21:46:41.187500000 +0100
+++ privatemsg.module	2008-09-01 21:46:30.640625000 +0100
@@ -558,7 +558,22 @@ function privatemsg_configure() {
     '#default_value' => variable_get('privatemsg_online_status', 1),
     '#options' => array('No', 'Yes'),
     '#description' => t('Whether to allow users to see if message author was recently online'),
-  );
+  );
+  // use imagecache preset and only show if presets are available
+  if (module_exists('imagecache') && is_array(($privatemsg_presets = imagecache_presets()))){
+    $privatemsg_presetselect = array();
+    foreach ($privatemsg_presets as $privatemsg_p){
+      $privatemsg_presetselect[$privatemsg_p['presetname']] = $privatemsg_p['presetname'];
+    }
+      
+    $form['privatemsg_imagecache_preset'] = array(
+      '#type' => 'select',
+      '#options' => $privatemsg_presetselect,
+      '#title' => t('Choose Imagecache Preset for Displaying Avatars in Message Queue'),
+      '#default_value' => variable_get('privatemsg_imagecache_preset', 1),
+      '#description' => t('In the list of private messages, what imagecache preset should be used to resize the avatar images.'),
+    );
+  }
   $form['privatemsg_menu_link'] = array(
     '#type' => 'textfield',
     '#title' => t('Menu link'),
@@ -653,7 +668,7 @@ function privatemsg_configure() {
     '#title' => t("'Aggressive notification of new messages' default"),
     '#default_value' => variable_get('privatemsg_default_setmessage_notify', 1),
     '#description' => t("Check this box to set the default value of the 'Aggressive notification of new messages' user setting."),
-  );
+  );
   return system_settings_form($form);
 }
 
@@ -895,7 +910,7 @@ function privatemsg_list_form($messages,
 
     $form['messages'][$message->id]['selected'] = array(
       '#type' => 'checkbox',
-    );
+    );    
     $form['messages'][$message->id]['avatar'] = array(
       '#value' => '<div class="pm-inbox-avatar">'. theme('privatemsg_user_picture', user_load(array('uid' => $message->uid))).'</div>',
     );
@@ -2506,8 +2521,21 @@ function theme_privatemsg_user_picture($
     }
 
     if (isset($picture)) {
-      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
-      $picture = theme('image', $picture, $alt, $alt, '', FALSE);
+      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
+
+      // add imagecache support
+      if (module_exists('imagecache') && is_array(imagecache_presets())){
+	// if $picture path begins with http:// (ie. it's elsewhere on the site) then let's reset to original location for it to work with imagecache
+	if (strpos($picture, 'http://') === 0){
+	  $picture = $account->picture;
+	}
+
+	$picture = theme('imagecache', variable_get('privatemsg_imagecache_preset', 1), $picture, $alt, $alt, false); 	// is 0 ok here as a default? i'd like to use the default user imagecache preset, but not too sure how to retrieve it!
+      }
+      else{
+	$picture = theme('image', $picture, $alt, $alt, '', FALSE);
+      }
+      
       if (!empty($account->uid) && user_access('access user profiles')) {
         $picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
       }
