From 1b2ce46df2f11783fb766f3d3811dab1c4acb986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= <gabor@hojtsy.hu> Date: Tue, 15 Jan 2008 10:17:42 +0000 Subject: [PATCH] #201540 follow up by zoo33: move jpeg quality validation to where it belongs, so it is only called if the current image toolkit requires it --- includes/image.gd.inc | 14 +++++++++++++- modules/system/system.admin.inc | 12 ------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/includes/image.gd.inc b/includes/image.gd.inc index 7ae60dcf113d..de887e35fc1c 100644 --- a/includes/image.gd.inc +++ b/includes/image.gd.inc @@ -37,7 +37,8 @@ function image_gd_settings() { '#default_value' => variable_get('image_jpeg_quality', 75), '#field_suffix' => t('%'), ); - + $form['#element_validate'] = array('image_gd_settings_validate'); + return $form; } else { @@ -46,6 +47,17 @@ function image_gd_settings() { } } +/** + * Validate the submitted GD settings. + */ +function image_gd_settings_validate($form, &$form_state) { + // Validate image quality range. + $value = $form_state['values']['image_jpeg_quality']; + if (!is_numeric($value) || $value < 0 || $value > 100) { + form_set_error('image_jpeg_quality', t('JPEG quality must be a number between 0 and 100.')); + } +} + /** * Verify GD2 settings (that the right version is actually installed). * diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 7adbcaab2fbe..af6e53c8a030 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -1425,22 +1425,10 @@ function system_image_toolkit_settings() { } $form['image_toolkit_settings'] = image_toolkit_invoke('settings'); - $form['#validate'][] = 'system_image_toolkit_settings_validate'; return system_settings_form($form); } -/** - * Validate the submitted image-toolkit form. - */ -function system_image_toolkit_settings_validate($form, &$form_state) { - // Validate image quality range. - $value = $form_state['values']['image_jpeg_quality']; - if (!is_numeric($value) || $value < 0 || $value > 100) { - form_set_error('image_jpeg_quality', t('JPEG quality must be a number between 0 and 100.')); - } -} - /** * Form builder; Configure how the site handles RSS feeds. * -- GitLab