diff --git a/core/includes/image.inc b/core/includes/image.inc index f6ae7f1..e8e0b0b 100644 --- a/core/includes/image.inc +++ b/core/includes/image.inc @@ -65,7 +65,7 @@ function image_get_toolkit() { if (!isset($toolkit)) { $toolkits = image_get_available_toolkits(); - $toolkit = variable_get('image_toolkit', 'gd'); + $toolkit = config('system.image')->get('toolkit'); if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) { // The selected toolkit isn't available so return the first one found. If // none are available this will return FALSE. diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php index fb3269c..7698ada 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php @@ -32,7 +32,6 @@ class ImageEffectsTest extends ToolkitTestBase { function setUp() { parent::setUp(); - module_load_include('inc', 'image', 'image.effects'); } diff --git a/core/modules/system/image.gd.inc b/core/modules/system/image.gd.inc index f6f12ae..0bf5fb7 100644 --- a/core/modules/system/image.gd.inc +++ b/core/modules/system/image.gd.inc @@ -25,7 +25,7 @@ function image_gd_settings() { '#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' => variable_get('image_jpeg_quality', 75), + '#default_value' => config('system.image.gd')->get('jpeg_quality'), '#field_suffix' => t('%'), ); @@ -38,6 +38,19 @@ function image_gd_settings() { } /** + * Form submission handler for image_gd_settings(). + * + * @see system_image_toolkit_settings_submit + */ +function image_gd_settings_submit($form, &$form_state) { + if (isset($form_state['values']['image_jpeg_quality'])) { + config('system.image.gd') + ->set('jpeg_quality', $form_state['values']['image_jpeg_quality']) + ->save(); + } +} + +/** * Verify GD2 settings (that the right version is actually installed). * * @return @@ -269,7 +282,7 @@ function image_gd_save(stdClass $image, $destination) { return FALSE; } if ($extension == 'jpeg') { - $success = $function($image->resource, $destination, variable_get('image_jpeg_quality', 75)); + $success = $function($image->resource, $destination, config('system.image.gd')->get('jpeg_quality')); } else { // Always save PNG images with full transparency. diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 8aa3ed4..2ba772d 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1867,39 +1867,54 @@ function system_file_system_settings() { * Form builder; Configure site image toolkit usage. * * @ingroup forms - * @see system_settings_form() + * @see system_image_toolkit_settings_submit() */ -function system_image_toolkit_settings() { +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) { - variable_del('image_toolkit'); - $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; - } + $form['image_toolkit'] = array( + '#type' => 'radios', + '#title' => t('Select an image processing toolkit'), + '#default_value' => $config->get('toolkit'), + '#options' => $toolkits_available, + ); - if (count($toolkits_available) > 1) { - $form['image_toolkit'] = array( - '#type' => 'radios', - '#title' => t('Select an image processing toolkit'), - '#default_value' => variable_get('image_toolkit', $current_toolkit), - '#options' => $toolkits_available - ); - } - else { - variable_set('image_toolkit', key($toolkits_available)); + // Get the toolkit's settings form. + foreach ($toolkits_available as $toolkit => $toolkit_name) { + $function = 'image_' . $toolkit . '_settings'; + if (function_exists($function)) { + $form['image_' . $toolkit . '_settings'] = array( + '#type' => 'fieldset', + '#title' => $toolkit_name . " Settings", + '#states' => array( + 'visible' => array( + ':input[name="image_toolkit"]' => array('value' => $toolkit), + ), + ), + ); + $form['image_' . $toolkit . '_settings']['image_toolkit_settings'] = $function(); + } } - // Get the toolkit's settings form. - $function = 'image_' . $current_toolkit . '_settings'; + return system_config_form($form, $form_state); +} + +/** + * Form submission handler for system_image_toolkit_settings(). + */ +function system_image_toolkit_settings_submit($form, &$form_state) { + config('system.image') + ->set('toolkit', $form_state['values']['image_toolkit']) + ->save(); + + // Call the form submit handler for the current toolkit. Calling + // image_get_toolkit() does the necessary includes. + $function = 'image_' . $form_state['values']['image_toolkit'] . '_settings_submit'; if (function_exists($function)) { - $form['image_toolkit_settings'] = $function(); + $function($form, $form_state); } - - return system_settings_form($form); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0e42214..970b549 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2008,6 +2008,7 @@ function system_update_8014() { $config->save(); } + /** * Create a UUID column for managed files. * @@ -2047,6 +2048,20 @@ function system_update_8016() { } /** + * Moves image toolkit settings from variable to config. + * + * @ingroup config_upgrade + */ +function system_update_8017() { + update_variables_to_config('system.image', array( + 'image_toolkit' => 'toolkit', + )); + update_variables_to_config('system.image.gd', array( + 'image_jpeg_quality' => 'jpeg_quality', + )); +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */