diff -u b/core/modules/system/config/system.image.yml b/core/modules/system/config/system.image.yml --- b/core/modules/system/config/system.image.yml +++ b/core/modules/system/config/system.image.yml @@ -2,2 +1,0 @@ -gd: - jpeg_quality: '75' diff -u b/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc --- b/core/modules/system/image.gd.inc +++ b/core/modules/system/image.gd.inc @@ -25,7 +25,7 @@ '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'), '#min' => 0, '#max' => 100, - '#default_value' => config('system.image')->get('gd.jpeg_quality'), + '#default_value' => config('system.image.gd')->get('jpeg_quality'), '#field_suffix' => t('%'), ); @@ -39,11 +39,12 @@ /** * Form submission handler for image_gd_settings(). + * * @see system_image_toolkit_settings_submit */ function image_gd_settings_submit($form, &$form_state) { - config('system.image') - ->set('gd.jpeg_quality', $form_state['values']['image_jpeg_quality']) + config('system.image.gd') + ->set('jpeg_quality', $form_state['values']['image_jpeg_quality']) ->save(); } @@ -279,7 +280,7 @@ return FALSE; } if ($extension == 'jpeg') { - $success = $function($image->resource, $destination, config('system.image')>get('gd.jpeg_quality')); + $success = $function($image->resource, $destination, config('system.image.gd')->get('jpeg_quality')); } else { // Always save PNG images with full transparency. diff -u b/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc --- b/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1854,33 +1854,32 @@ * Form builder; Configure site image toolkit usage. * * @ingroup forms - * @see system_config_form() + * @see system_image_toolkit_settings_submit() */ function system_image_toolkit_settings($form, &$form_state) { + $config = config('system.image'); $toolkits_available = image_get_available_toolkits(); $current_toolkit = image_get_toolkit(); if (count($toolkits_available) == 0) { + $config->set('toolkit', '')->save(); $form['image_toolkit_help'] = array( '#markup' => t("No image toolkits were detected. Drupal includes support for PHP's built-in image processing functions but they were not detected on this system. You should consult your system administrator to have them enabled, or try using a third party toolkit.", array('gd-link' => url('http://php.net/gd'))), ); return $form; } - if (count($toolkits_available) > 1) { - $form['image_toolkit'] = array( - '#type' => 'radios', - '#title' => t('Select an image processing toolkit'), - '#default_value' => config('system.image')->get('toolkit'), - '#options' => $toolkits_available - ); - } - else { - $form['image_toolkit'] = array( - '#type' => 'value', - '#value' => $current_toolkit, - ); - config('system.image')->set('toolkit', key($toolkits_available))->save(); + $form['image_toolkit'] = array( + '#type' => 'radios', + '#title' => t('Select an image processing toolkit'), + '#default_value' => $config->get('toolkit'), + '#options' => $toolkits_available, + '#access' => count($toolkits_available) > 1, + ); + + if (count($toolkits_available) == 1) { + // Set the image toolkit to the one only available. + $config->set('toolkit', key($toolkits_available))->save(); } // Get the toolkit's settings form. @@ -1888,6 +1887,7 @@ if (function_exists($function)) { $form['image_toolkit_settings'] = $function(); } + return system_config_form($form, $form_state); } @@ -1895,13 +1895,13 @@ * Form submission handler for system_image_toolkit_settings(). */ function system_image_toolkit_settings_submit($form, &$form_state) { - $current_toolkit = $form_state['values']['image_toolkit']; config('system.image') - ->set('toolkit', $current_toolkit) + ->set('toolkit', $form_state['values']['image_toolkit']) ->save(); - // Allow toolkit to save its own seetings. - $function = 'image_' . $current_toolkit . '_settings_submit'; + // Call the form submit handler for the current toolkit. Calling + // image_get_toolkit() does the necessary includes. + $function = 'image_' . image_get_toolkit() . '_settings_submit'; if (function_exists($function)) { $function($form, $form_state); } diff -u b/core/modules/system/system.install b/core/modules/system/system.install --- b/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2006,7 +2006,9 @@ function system_update_8015() { update_variables_to_config('system.image', array( 'image_toolkit' => 'toolkit', - 'image_jpeg_quality' => 'gd.jpeg_quality', + )); + update_variables_to_config('system.image.gd', array( + 'image_jpeg_quality' => 'jpeg_quality', )); } only in patch2: unchanged: --- a/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php @@ -23,7 +23,7 @@ class ImageEffectsTest extends ToolkitTestBase { } function setUp() { - parent::setUp('image_test'); + parent::setUp(); module_load_include('inc', 'image', 'image.effects'); } only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/config/system.image.gd.yml @@ -0,0 +1 @@ +jpeg_quality: '75' only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php @@ -19,7 +19,7 @@ abstract class ToolkitTestBase extends WebTestBase { protected $image; function setUp() { - parent::setUp('image_test'); + parent::setUp(array('image', 'image_test')); // Use the image_test.module's test toolkit. $this->toolkit = 'test';