? image.styles.851878.15.patch ? image.styles.patch ? sites/default/files ? sites/default/settings.php Index: modules/image/image.module =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.module,v retrieving revision 1.43 diff -u -p -r1.43 image.module --- modules/image/image.module 31 May 2010 11:42:11 -0000 1.43 +++ modules/image/image.module 23 Jul 2010 20:19:46 -0000 @@ -71,10 +71,10 @@ function image_help($path, $arg) { function image_menu() { $items = array(); - $items['image/generate/%image_style'] = array( + $items[file_directory_path() . '/styles/%image_style'] = array( 'title' => 'Generate image style', 'page callback' => 'image_style_generate', - 'page arguments' => array(2), + 'page arguments' => array(count(explode('/', file_directory_path())) + 2), 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -632,19 +632,16 @@ function image_style_generate() { $path = implode('/', $args); $path = $scheme . '://' . $path; - $path_hash = drupal_hash_base64($path); $destination = image_style_path($style['name'], $path); - // Check that it's a defined style and that access was granted by - // image_style_url(). - if (!$style || !cache_get('access:' . $style_name . ':' . $path_hash, 'cache_image')) { - drupal_access_denied(); + // Check that it's a defined style. + if (!$style) { drupal_exit(); } // Don't start generating the image if the derivate already exists or if // generation is in progress in another thread. - $lock_name = 'image_style_generate:' . $style_name . ':' . $path_hash; + $lock_name = 'image_style_generate:' . $style_name . ':' . drupal_hash_base64($path); if (!file_exists($destination)) { $lock_acquired = lock_acquire($lock_name); if (!$lock_acquired) { @@ -753,13 +750,6 @@ function image_style_flush($style) { /** * Return the URL for an image derivative given a style and image path. * - * This function is the default image generation method. It returns a URL for - * an image that can be used in an tag. When the browser requests the - * image at image/generate/[style_name]/[scheme]/[path] the image is generated - * if it does not already exist and then served to the browser. This allows - * each image to have its own PHP instance (and memory limit) for generation of - * the new image. - * * @param $style_name * The name of the style to be used with this image. * @param $path @@ -771,25 +761,12 @@ function image_style_flush($style) { */ function image_style_url($style_name, $path) { $destination = image_style_path($style_name, $path); - - // If the image already exists use that rather than regenerating it. - if (file_exists($destination)) { - return file_create_url($destination); + $url = file_directory_path() . '/' . file_uri_target($destination); + // If clean urls are disabled, then we need to prepend '?q=' to the image url + // so that the file will be served by php. + if (!variable_get('clean_url', FALSE)) { + $url = '?q=' . $url; } - - // Disable page cache for this request. This prevents anonymous users from - // needlessly hitting the image generation URL when the image already exists. - drupal_page_is_cacheable(FALSE); - - // Set a cache entry to grant access to this style/image path. This will be - // checked by image_style_generate(). - cache_set('access:' . $style_name . ':' . drupal_hash_base64($path), 1, 'cache_image', REQUEST_TIME + 600); - - $scheme = file_uri_scheme($path); - $target = file_uri_target($path); - - // Generate a callback path for the image. - $url = url('image/generate/' . $style_name . '/' . $scheme . '/' . $target, array('absolute' => TRUE)); return $url; } @@ -816,7 +793,7 @@ function image_style_path($style_name, $ $path = $uri; $scheme = variable_get('file_default_scheme', 'public'); } - return $scheme . '://styles/' . $style_name . '/' . $path; + return $scheme . '://styles/' . $style_name . '/' . $scheme . '/' . $path; } /** @@ -1079,7 +1056,7 @@ function theme_image_style($variables) { if (!file_exists($style_path)) { $style_path = image_style_url($style_name, $path); } - $variables['path'] = file_create_url($style_path); + $variables['path'] = $style_path; $variables['getsize'] = FALSE; return theme('image', $variables); }