diff --git a/avatar_selection.admin.inc b/avatar_selection.admin.inc index 2526fa7..f1906b5 100644 --- a/avatar_selection.admin.inc +++ b/avatar_selection.admin.inc @@ -147,6 +147,22 @@ function avatar_selection_config_form() { '#default_value' => variable_get('avatar_selection_distinctive_avatars', FALSE), ); + if (module_exists("imagecache")) { + // Load imagecache presets + $presets = array(); + $presets[] = ''; + foreach (imagecache_presets() as $preset) { + $presets[$preset['presetname']] = check_plain($preset['presetname']); + } + + $form['update']['imagecache_preset'] = array( + '#type' => 'select', + '#title' => t('Imagecache preset'), + '#default_value' => variable_get('avatar_selection_imagecache_preset', FALSE), + '#options' => $presets, + '#description' => t("You can choose an imagecache preset to format the avatars."), + ); + } $form['update']['submit'] = array( '#type' => 'submit', @@ -557,6 +573,9 @@ function avatar_selection_config_form_submit($form, &$form_state) { variable_set('avatar_selection_avatar_per_page', $form_state['values']['avatar_per_page']); variable_set('avatar_selection_set_random_default', $form_state['values']['set_random_default']); variable_set('avatar_selection_distinctive_avatars', $form_state['values']['distinctive_avatars']); + if (module_exists("imagecache")) { + variable_set('avatar_selection_imagecache_preset', $form_state['values']['imagecache_preset']); + } drupal_set_message(t('Configuration has been updated.')); } } diff --git a/avatar_selection.module b/avatar_selection.module index 029ab6a..f027c12 100644 --- a/avatar_selection.module +++ b/avatar_selection.module @@ -467,10 +467,19 @@ function _avatar_selection_image_list($user = "", $set_type = "", $set_id = 0, $ } } + if (module_exists("imagecache")) { + $imagecache_preset = variable_get('avatar_selection_imagecache_preset', 0); + } + while ($avatar = db_fetch_object($result)) { $avs_image = $avatar->avatar; $name = $avatar->name; - $avatars[$avs_image] = theme('image', $url .'/'. $avs_image, $name, $name, NULL, FALSE); + if (module_exists("imagecache") && $imagecache_preset) { + $avatars[$avs_image] = theme('imagecache', $imagecache_preset, $dir . '/' . $avs_image, $name, $name); + } + else { + $avatars[$avs_image] = theme('image', $url .'/'. $avs_image, $name, $name, NULL, FALSE); + } } $selects['avatars'] = $avatars; $selects['total'] = $total;