? privatemsg_avatar_2.patch
Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.37
diff -u -r1.70.2.37 privatemsg.module
--- privatemsg.module	14 Jun 2008 06:17:05 -0000	1.70.2.37
+++ privatemsg.module	1 Sep 2008 23:31:36 -0000
@@ -559,6 +559,23 @@
     '#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(
+      0 => t('Select ImageCache Preset'),
+    );
+    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', 0),
+      '#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'),
@@ -895,7 +912,7 @@
 
     $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>',
     );
@@ -2482,37 +2499,42 @@
 
 function theme_privatemsg_user_picture($account) {
   if (variable_get('user_pictures', 0)) {
+    
     if ($account->picture && file_exists($account->picture)) {
-
-      if (arg(0) == 'user' && is_numeric(arg(1))) { // If on user profile page       
-        $picture = file_create_url($account->picture);
-      }
-      else { // somewhere else on the site - use small pic
-        $info = image_get_info($account->picture);
-        $newpicture = dirname($account->picture) . '/picture-' . $account->uid . "-avatar." . $info['extension'];
-        
-        if (!file_exists($newpicture) || (filectime($newpicture) < filectime($account->picture))) {
-          image_scale($account->picture, $newpicture, 64, 64); 
-          if (!file_exists($newpicture)) {
-            $newpicture = $account->picture;
-          }
-        }
-        
-        $picture = file_create_url($newpicture);
-      } 
+      $picture = $account->picture;
     }
-    else if (variable_get('user_picture_default', '')) {
+    else {
       $picture = variable_get('user_picture_default', '');
     }
-
-    if (isset($picture)) {
-      $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
+    
+    $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
+    $presets = imagecache_preset_by_name(variable_get('privatemsg_imagecache_preset', 0));
+    if ( strpos($picture, 'http://') === FALSE && module_exists('imagecache') && !empty($presets) && variable_get('privatemsg_imagecache_preset', 0) ) {
+      $picture = theme('imagecache', variable_get('privatemsg_imagecache_preset', 0), $picture, $alt, $alt, false); 
+    } 
+    else {
+      $info = image_get_info($picture);
+      $newpicture = dirname($picture) . '/picture-' . $account->uid . "-avatar." . $info['extension'];
+      
+      if (!file_exists($newpicture) || (filectime($newpicture) < filectime($picture))) {
+        image_scale($picture, $newpicture, 64, 64); 
+        if (!file_exists($newpicture)) {
+          $newpicture = $picture;
+        }
+      }
+      $picture = file_create_url($newpicture);  
       $picture = theme('image', $picture, $alt, $alt, '', FALSE);
+    }
+    
+    
+    
+    
+    if (isset($picture)) {
       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);
       }
       if (variable_get('privatemsg_online_status', 1)) {
-  // code to show online/offline status
+        // code to show online/offline status
         $time_period = variable_get('user_block_seconds_online', 1200);
         $uid = $account->uid; // get the current userid for the avatar.
         $users = db_query("SELECT uid, name, access FROM {users} WHERE access >= %d AND uid = %s", time() - $time_period, $uid);
