summaryrefslogtreecommitdiff
path: root/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/user.admin.inc10
-rw-r--r--modules/user/user.module26
-rw-r--r--modules/user/user.test3
3 files changed, 36 insertions, 3 deletions
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index fede3de58..2be697195 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -360,6 +360,14 @@ function user_admin_settings() {
'#maxlength' => 255,
'#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
);
+ if (module_exists('image')) {
+ $form['personalization']['pictures']['settings']['user_picture_style'] = array(
+ '#type' => 'select',
+ '#title' => t('Picture style'),
+ '#options' => image_style_options(TRUE),
+ '#default_value' => variable_get('user_picture_style', ''),
+ );
+ }
$form['personalization']['pictures']['user_picture_dimensions'] = array(
'#type' => 'textfield',
'#title' => t('Picture maximum dimensions'),
@@ -456,7 +464,7 @@ function user_admin_settings() {
'#default_value' => _user_mail_text('register_no_approval_required_body'),
'#rows' => 15,
);
-
+
$form['email_password_reset'] = array(
'#type' => 'fieldset',
'#title' => t('Password recovery'),
diff --git a/modules/user/user.module b/modules/user/user.module
index 3072ae2ef..ac7f6cbff 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1176,7 +1176,12 @@ function template_preprocess_user_picture(&$variables) {
}
if (isset($filepath)) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
- $variables['picture'] = theme('image', $filepath, $alt, $alt, '', FALSE);
+ if (module_exists('image') && $style = variable_get('user_picture_style', '')) {
+ $variables['picture'] = theme('image_style', $style, $filepath, $alt, $alt, NULL, FALSE);
+ }
+ else {
+ $variables['picture'] = theme('image', $filepath, $alt, $alt, NULL, 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);
@@ -2653,6 +2658,25 @@ function user_node_load($nodes, $types) {
}
/**
+ * Implement hook_image_style_delete().
+ */
+function user_image_style_delete($style) {
+ // If a style is deleted, update the variables.
+ // Administrators choose a replacement style when deleting.
+ user_image_style_save($style);
+}
+
+/**
+ * Implement hook_image_style_save().
+ */
+function user_image_style_save($style) {
+ // If a style is renamed, update the variables that use it.
+ if (isset($style['old_name']) && $style['old_name'] == variable_get('user_picture_style', '')) {
+ variable_set('user_picture_style', $style['name']);
+ }
+}
+
+/**
* Implement hook_hook_info().
*/
function user_hook_info() {
diff --git a/modules/user/user.test b/modules/user/user.test
index 2683dfb32..ee77d0dcc 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -563,7 +563,8 @@ class UserPictureTestCase extends DrupalWebTestCase {
$text = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $test_dim));
$this->assertRaw($text, t('Image was resized.'));
$alt = t("@user's picture", array('@user' => $this->user->name));
- $this->assertRaw(theme('image', $pic_path, $alt, $alt, '', FALSE), t("Image is displayed in user's edit page"));
+ $style = variable_get('user_picture_style', '');
+ $this->assertRaw(image_style_url($style, $pic_path), t("Image is displayed in user's edit page"));
// Check if file is located in proper directory.
$this->assertTrue(is_file($pic_path), t("File is located in proper directory"));