Index: imagecache_profiles.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache_profiles/imagecache_profiles.module,v
retrieving revision 1.5
diff -u -p -r1.5 imagecache_profiles.module
--- imagecache_profiles.module	19 Dec 2008 18:12:56 -0000	1.5
+++ imagecache_profiles.module	7 Feb 2009 13:47:13 -0000
@@ -22,9 +22,9 @@ function imagecache_profiles_help($path,
  * @see user-picture.tpl.php
  */
 function imagecache_profiles_preprocess_user_picture(&$variables) {
-  $variables['picture'] = '';
+  $default = $variables['picture'];
   if (variable_get('user_pictures', 0)) {
-    $account = $variables['account'];    
+    $account = $variables['account'];
     // Determine imagecache preset to use for user profile picture
     // First let's determine if we have a default imagecache preset
     if (variable_get('user_picture_imagecache_profiles_default', 0)) {
@@ -43,7 +43,12 @@ function imagecache_profiles_preprocess_
         $size = variable_get('user_picture_imagecache_comments', 0);
       }
     }
-    
+
+    // If views set an imagecache preset
+    if ($account->imagecache_preset) {
+    	$size = $account->imagecache_preset;
+    }
+
     if (!empty($account->picture) && file_exists($account->picture)) {
       $picture = $account->picture;
     }
@@ -53,14 +58,15 @@ function imagecache_profiles_preprocess_
 
     if (isset($picture)) {
       $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
-      if (isset($size)) {
-        $variables['picture'] = theme('imagecache', $size, $picture, $alt, $alt);
+      $preset = imagecache_preset($size);
+      if (empty($preset)) {
+        $variables['picture'] = $default;//theme('image', $picture, $alt, $alt, '', FALSE);
       } else {
-        $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
-      }      
-      if (!empty($account->uid) && user_access('access user profiles')) {
-        $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
-        $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
+        $variables['picture'] = theme('imagecache', $preset['presetname'], $picture, $alt, $alt);
+        if (!empty($account->uid) && user_access('access user profiles')) {
+          $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
+          $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
+        }
       }
     }
   }
@@ -69,7 +75,7 @@ function imagecache_profiles_preprocess_
 /**
  * Implementation of hook_form_alter().
  */
-function imagecache_profiles_form_alter(&$form, $form_state, $form_id) {  
+function imagecache_profiles_form_alter(&$form, $form_state, $form_id) {
   switch($form_id) {
     case 'user_profile_form':
       $form['#validate'][] = 'imagecache_profiles_user_profile_form_validate';
@@ -77,11 +83,10 @@ function imagecache_profiles_form_alter(
       
     case 'user_admin_settings':
       // Load imagecache presets
-      $result = db_query('SELECT presetid, presetname FROM {imagecache_preset} ORDER BY presetname');
       $presets = array();
       $presets[] = '';
-      while ($data = db_fetch_object($result)) {
-        $presets[check_plain($data->presetname)] = check_plain($data->presetname);
+      foreach (imagecache_presets() as $key => $preset) {
+      	$presets[$key] = check_plain($preset['presetname']);
       }
       
       $form['pictures']['settings']['user_picture_imagecache_profiles'] = array(
@@ -159,4 +164,10 @@ function imagecache_profiles_user($op, &
       imagecache_image_flush($edit['picture']);
     }
   }
-}
\ No newline at end of file
+}
+function imagecache_profiles_views_api() {
+  return array(
+    'api' => 2,
+    'path' => drupal_get_path('module', 'imagecache_profiles') .'/views',
+  );
+}
