diff options
-rw-r--r-- | includes/bootstrap.inc | 2 | ||||
-rw-r--r-- | includes/image.inc | 31 | ||||
-rw-r--r-- | modules/system/image.gd.inc (renamed from includes/image.gd.inc) | 0 | ||||
-rw-r--r-- | modules/system/system.info | 1 | ||||
-rw-r--r-- | modules/system/system.module | 7 |
5 files changed, 25 insertions, 16 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 626b87405..63f704a1d 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -1175,7 +1175,7 @@ function ip_address($reset = false) { if (!isset($ip_address) || $reset) { $ip_address = $_SERVER['REMOTE_ADDR']; - + if (variable_get('reverse_proxy', 0)) { if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { // If an array of known reverse proxy IPs is provided, then trust diff --git a/includes/image.inc b/includes/image.inc index d86b62b01..44eca9f3c 100644 --- a/includes/image.inc +++ b/includes/image.inc @@ -21,11 +21,13 @@ * from this problem, but it requires the ISP to have installed additional * software. * - * Image toolkits are installed by copying the image.ToolkitName.inc file into - * Drupal's includes directory. The toolkit must then be enabled using the - * admin/settings/image-toolkit form. + * Image toolkits are discovered based on the associated module's + * hook_image_toolkits. Additionally the image toolkit include file + * must be identified in the files array in the module.info file. The + * toolkit must then be enabled using the admin/settings/image-toolkit + * form. * - * Only one toolkit maybe selected at a time. If a module author wishes to call + * Only one toolkit may be selected at a time. If a module author wishes to call * a specific toolkit they can check that it is installed by calling * image_get_available_toolkits(), and then calling its functions directly. */ @@ -37,18 +39,17 @@ * An array of toolkit name => descriptive title. */ function image_get_available_toolkits() { - $toolkits = file_scan_directory('includes', 'image\..*\.inc$'); + // hook_image_toolkits returns an array of toolkit names. + $toolkits = module_invoke_all('image_toolkits'); $output = array(); - foreach ($toolkits as $file => $toolkit) { - include_once "./$file"; - $function = str_replace('.', '_', $toolkit->name) . '_info'; - if (function_exists($function)) { + foreach ($toolkits as $name) { + $function = 'image_' . $name . '_info'; + if (drupal_function_exists($function)) { $info = $function(); $output[$info['name']] = $info['title']; } } - return $output; } @@ -63,11 +64,11 @@ function image_get_toolkit() { if (!$toolkit) { $toolkit = variable_get('image_toolkit', 'gd'); - $toolkit_file = './includes/image.' . $toolkit . '.inc'; - if (isset($toolkit) && file_exists($toolkit_file)) { - include_once $toolkit_file; + if (isset($toolkit) && + drupal_function_exists("image_" . $toolkit . "_resize")) { } - elseif (!image_gd_check_settings()) { + elseif (!drupal_function_exists("image_gd_check_settings") || + !image_gd_check_settings()) { $toolkit = FALSE; } } @@ -88,7 +89,7 @@ function image_get_toolkit() { function image_toolkit_invoke($method, $params = array()) { if ($toolkit = image_get_toolkit()) { $function = 'image_' . $toolkit . '_' . $method; - if (function_exists($function)) { + if (drupal_function_exists($function)) { return call_user_func_array($function, $params); } else { diff --git a/includes/image.gd.inc b/modules/system/image.gd.inc index ab26371f6..ab26371f6 100644 --- a/includes/image.gd.inc +++ b/modules/system/image.gd.inc diff --git a/modules/system/system.info b/modules/system/system.info index 649436908..983331437 100644 --- a/modules/system/system.info +++ b/modules/system/system.info @@ -6,3 +6,4 @@ version = VERSION core = 7.x files[] = system.module files[] = system.admin.inc +files[] = image.gd.inc diff --git a/modules/system/system.module b/modules/system/system.module index b34c39f55..b1e5d2897 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2105,3 +2105,10 @@ function theme_meta_generator_html($version = VERSION) { function theme_meta_generator_header($version = VERSION) { drupal_set_header('X-Generator: Drupal ' . $version . ' (http://drupal.org)'); } + +/** + * Implementation of hook_image_toolkits(). + */ +function system_image_toolkits() { + return array('gd'); +} |