diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-08-21 16:51:52 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-08-21 16:51:52 +0000 |
commit | 19638ba0c60bc9bdd147a232c0a237fc371613a5 (patch) | |
tree | 3dbc16f5dcde62533d44c56d9d3b8c9cd603334f /modules | |
parent | e4758cb4f546cec4cba394c5e3578b4263b7e8d9 (diff) | |
download | brdo-19638ba0c60bc9bdd147a232c0a237fc371613a5.tar.gz brdo-19638ba0c60bc9bdd147a232c0a237fc371613a5.tar.bz2 |
- Patch #523478 by stBorchert, Bojhan, et al: better widget for WIDTH x HEIGHT widget.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/upload/upload.admin.inc | 38 | ||||
-rw-r--r-- | modules/upload/upload.module | 2 | ||||
-rw-r--r-- | modules/upload/upload.test | 2 |
3 files changed, 30 insertions, 12 deletions
diff --git a/modules/upload/upload.admin.inc b/modules/upload/upload.admin.inc index fbd2d7b0f..6d728d363 100644 --- a/modules/upload/upload.admin.inc +++ b/modules/upload/upload.admin.inc @@ -10,10 +10,11 @@ * Form API callback to validate the upload settings form. */ function upload_admin_settings_validate($form, &$form_state) { - if (($form_state['values']['upload_max_resolution'] != '0')) { - if (!preg_match('/^[0-9]+x[0-9]+$/', $form_state['values']['upload_max_resolution'])) { - form_set_error('upload_max_resolution', t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction.')); - } + if (!is_numeric($form_state['values']['upload_max_resolution_x'])) { + form_set_error('upload_max_resolution_x', t('The maximum allowed image width should be entered as a numeric value. Set to 0 for no restriction.')); + } + if (!is_numeric($form_state['values']['upload_max_resolution_y'])) { + form_set_error('upload_max_resolution_y', t('The maximum allowed image height should be entered as a numeric value. Set to 0 for no restriction.')); } $default_uploadsize = $form_state['values']['upload_uploadsize_default']; @@ -68,15 +69,32 @@ function upload_admin_settings() { '#type' => 'fieldset', '#title' => t('General settings'), '#collapsible' => TRUE, + '#attached_css' => array( + drupal_get_path('module', 'upload') . '/upload.admin.css', + ), ); $form['settings_general']['upload_max_resolution'] = array( - '#type' => 'textfield', + '#type' => 'item', '#title' => t('Maximum resolution for uploaded images'), - '#default_value' => variable_get('upload_max_resolution', 0), - '#size' => 15, - '#maxlength' => 10, - '#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0 for no restriction. If an <a href="!image-toolkit-link">image toolkit</a> is installed, files exceeding this value will be scaled down to fit.', array('!image-toolkit-link' => url('admin/config/media/image-toolkit'))), - '#field_suffix' => '<kbd>' . t('WIDTHxHEIGHT') . '</kbd>' + '#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0x0 for no restriction. If an <a href="!image-toolkit-link">image toolkit</a> is installed, files exceeding this value will be scaled down to fit.', array('!image-toolkit-link' => url('admin/settings/image-toolkit'))), + '#prefix' => '<div class="form-item-wrapper form-item-resolution">', + '#suffix' => '</div>', + ); + $form['settings_general']['upload_max_resolution']['upload_max_resolution_x'] = array( + '#type' => 'textfield', + '#title' => t('Width'), + '#default_value' => variable_get('upload_max_resolution_x', 0), + '#size' => 5, + '#maxlength' => 5, + '#field_suffix' => t('x'), + ); + $form['settings_general']['upload_max_resolution']['upload_max_resolution_y'] = array( + '#type' => 'textfield', + '#title' => t('Height'), + '#default_value' => variable_get('upload_max_resolution_y', 0), + '#size' => 5, + '#maxlength' => 5, + '#field_suffix' => t('px'), ); $form['settings_general']['upload_list_default'] = array( '#type' => 'select', diff --git a/modules/upload/upload.module b/modules/upload/upload.module index d202291dd..e1f86db7a 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -142,7 +142,7 @@ function _upload_file_limits($user) { 'extensions' => $all_extensions, 'file_size' => $file_limit, 'user_size' => $user_limit, - 'resolution' => variable_get('upload_max_resolution', 0), + 'resolution' => variable_get('upload_max_resolution_x', 0) . 'x' . variable_get('upload_max_resolution_y', 0), ); } diff --git a/modules/upload/upload.test b/modules/upload/upload.test index da0aafe6a..e855a8237 100644 --- a/modules/upload/upload.test +++ b/modules/upload/upload.test @@ -177,7 +177,7 @@ class UploadTestCase extends DrupalWebTestCase { $edit = array(); foreach ($settings as $key => $value) { $edit[$key . '_default'] = $value; - if ($rid !== NULL && $key != 'upload_list' && $key != 'upload_max_resolution') { + if ($rid !== NULL && $key != 'upload_list' && $key != 'upload_max_resolution_x' && $key != 'upload_max_resolution_y') { $edit[$key . '_' . $rid] = $value; } } |