Index: imagecache_profiles.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagecache_profiles/imagecache_profiles.module,v retrieving revision 1.4.2.16 diff -u -p -r1.4.2.16 imagecache_profiles.module --- imagecache_profiles.module 25 Mar 2010 10:58:23 -0000 1.4.2.16 +++ imagecache_profiles.module 27 Jul 2010 17:20:17 -0000 @@ -26,34 +26,18 @@ function imagecache_profiles_preprocess_ $default = $variables['picture']; if (variable_get('user_pictures', 0)) { $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)) { - // Define default user picture size - $size = variable_get('user_picture_imagecache_profiles_default', 0); - } - // If on user profile page. - 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_imagecache_profiles', 0)) { - $size = variable_get('user_picture_imagecache_profiles', 0); - } - } - } - } - // If viewing a comment - if (is_object($account) && array_key_exists('cid', get_object_vars($account))) { - if (variable_get('user_picture_imagecache_comments', 0)) { - $size = variable_get('user_picture_imagecache_comments', 0); - } - } - // If views set an imagecache preset if (isset($account->imagecache_preset)) { - $size = $account->imagecache_preset; + // Manually set preset (e.g. Views) + $preset = $account->imagecache_preset; + } + elseif (!empty($account->cid) && variable_get('user_picture_imagecache_comments', 0)) { + // Comment user picture preset. + $preset = variable_get('user_picture_imagecache_comments', 0); + } + elseif (variable_get('user_picture_imagecache_profiles_default', 0)) { + // Default user picture preset. + $preset = variable_get('user_picture_imagecache_profiles_default', 0); } if (!empty($account->picture) && file_exists($account->picture)) { @@ -65,7 +49,7 @@ function imagecache_profiles_preprocess_ if (isset($picture)) { $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')))); - $preset = is_numeric($size) ? imagecache_preset($size) : imagecache_preset_by_name($size); + $preset = is_numeric($preset) ? imagecache_preset($preset) : imagecache_preset_by_name($preset); if (empty($preset)) { $variables['picture'] = $default; //theme('image', $picture, $alt, $alt, '', FALSE); } @@ -277,6 +261,21 @@ function imagecache_profiles_user($op, & } /** + * Implements hook_profile_alter(). + * + * Change the user profile user picture to use the preferred imagecache preset. + */ +function imagecache_profiles_profile_alter(&$account) { + if (isset($account->content['user_picture']) && $preset = variable_get('user_picture_imagecache_profiles', 0)) { + $account->imagecache_preset = $preset; + $account->content['user_picture'] = array( + '#value' => theme('user_picture', $account), + '#weight' => -10, + ); + } +} + +/** * Implements hook_views_api(). */ function imagecache_profiles_views_api() {