Index: imagecache_profiles.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache_profiles/imagecache_profiles.info,v
retrieving revision 1.3
diff -u -p -r1.3 imagecache_profiles.info
--- imagecache_profiles.info	19 Mar 2010 18:50:12 -0000	1.3
+++ imagecache_profiles.info	27 Jul 2010 19:27:06 -0000
@@ -1,9 +1,7 @@
 ; $Id: imagecache_profiles.info,v 1.3 2010/03/19 18:50:12 andypost Exp $
 name = Imagecache Profile Pictures
 description = Utilizes image styles for user profile pictures.
-package = ImageCache
 core = 7.x
-version = VERSION
 dependencies[] = image
 files[] = imagecache_profiles.install
 files[] = imagecache_profiles.module
Index: imagecache_profiles.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache_profiles/imagecache_profiles.module,v
retrieving revision 1.16
diff -u -p -r1.16 imagecache_profiles.module
--- imagecache_profiles.module	19 Mar 2010 18:50:12 -0000	1.16
+++ imagecache_profiles.module	27 Jul 2010 19:27:06 -0000
@@ -24,61 +24,42 @@ function imagecache_profiles_help($path,
  */
 function imagecache_profiles_preprocess_user_picture(&$variables) {
   if (variable_get('user_pictures', 0)) {
-    // Check if defaults should be overriden.
-    if (arg(0) == 'user') {
-      // Only show profile image for profile page, and edit account form,
-      // not user/123/relationships or other module define pages.
-      if (arg(2) == NULL || arg(2) == 'edit') {
-        if (is_numeric(arg(1)) || (module_exists('me') && arg(1) == me_variable_get('me_alias'))) {
-          if (variable_get('user_picture_style_profiles')) {
-            $style = variable_get('user_picture_style_profiles');
-          }
-        }
-      }
-    }
-
     $account = $variables['account'];
-    if (is_object($account)) {
-      $props = get_object_vars($account);
-
-      if (isset($account->imagecache_preset)) {
-        // If views set an imagecache preset.
-        $style = $account->imagecache_preset;
+    if (!empty($account->picture)) {
+      // @TODO: Ideally this function would only be passed file objects, but
+      // since there's a lot of legacy code that JOINs the {users} table to
+      // {node} or {comments} and passes the results into this function if we
+      // a numeric value in the picture field we'll assume it's a file id
+      // and load it for them. Once we've got user_load_multiple() and
+      // comment_load_multiple() functions the user module will be able to load
+      // the picture files in mass during the object's load process.
+      if (is_numeric($account->picture)) {
+        $account->picture = file_load($account->picture);
       }
-      else if (isset($account->cid) && isset($account->subject) && variable_get('user_picture_style_comments')) {
-        // If viewing a comment.
-        // TODO: check preview and use global $user.
-        $style = variable_get('user_picture_style_comments');
+      if (!empty($account->picture->uri)) {
+        $filepath = $account->picture->uri;
       }
     }
+    elseif (variable_get('user_picture_default', '')) {
+      $filepath = variable_get('user_picture_default', '');
+    }
 
-    if (isset($style) && $style != variable_get('user_picture_style')) {
-      // Override defined and different from default.
-      if (!empty($account->picture)) {
-        // @TODO: Ideally this function would only be passed file objects, but
-        // since there's a lot of legacy code that JOINs the {users} table to
-        // {node} or {comments} and passes the results into this function if we
-        // a numeric value in the picture field we'll assume it's a file id
-        // and load it for them. Once we've got user_load_multiple() and
-        // comment_load_multiple() functions the user module will be able to load
-        // the picture files in mass during the object's load process.
-        if (is_numeric($account->picture)) {
-          $account->picture = file_load($account->picture);
-        }
-        if (!empty($account->picture->uri)) {
-          $filepath = $account->picture->uri;
-        }
-      }
-      elseif (variable_get('user_picture_default')) {
-        $filepath = variable_get('user_picture_default');
-      }
-      if (isset($filepath)) {
-        $alt = t("@user's picture", array('@user' => format_username($account)));
-        $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array(), 'getsize' => FALSE));
-        if (!empty($account->uid) && user_access('access user profiles')) {
-          $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
-          $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
-        }
+    if (isset($variables['user_picture_style'])) {
+      $style = $variables['user_picture_style'];
+    }
+    elseif (isset($account->picture->style_name)) {
+      $style = $account->picture->style_name;
+    }
+    elseif (isset($account->user_picture_style)) {
+      $style = $account->user_picture_style;
+    }
+
+    if (isset($filepath) && !empty($style) && $style != variable_get('user_picture_style', '')) {
+      $alt = t("@user's picture", array('@user' => format_username($account)));
+      $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array(), 'getsize' => FALSE));
+      if (!empty($account->uid) && user_access('access user profiles')) {
+        $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
+        $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
       }
     }
   }
@@ -124,7 +105,6 @@ function imagecache_profiles_form_user_a
     '#description' => t('Minimum height dimension for picture, in pixels. To prevent upscaling this value should be set to your maximum imagecache preset height.'),
     '#size' => 10,
   );
-
 }
 
 /**
@@ -164,6 +144,32 @@ function imagecache_profiles_image_style
 }
 
 /**
+ * Implements hook_user_view_alter().
+ *
+ * Change the user profile user picture to use the preferred imagecache preset.
+ */
+function imagecache_profiles_user_view_alter(&$build) {
+  if (isset($build['user_picture']['#markup']) && $style = variable_get('user_picture_style_profiles', '')) {
+    $picture = theme('user_picture', array('account' => $build['#account'], 'user_picture_style' => $style));
+    $build['user_picture']['#markup'] = $picture;
+  }
+}
+
+/**
+ * Implements hook_comment_view().
+ */
+function imagecache_profiles_comment_view(&$comment) {
+  // If this is a comment preview, we need to manually add $comment->picture.
+  if (!isset($comment->picture) && !empty($comment->uid)) {
+    $comment->picture = db_query("SELECT picture FROM {users} WHERE uid = :uid", array(':uid' => $comment->uid))->fetchField();
+  }
+
+  if (!empty($comment->picture) && $style = variable_get('user_picture_style_comments', '')) {
+    $comment->user_picture_style = $style;
+  }
+}
+
+/**
  * Implements hook_views_api().
  *
  * Not tested.
