Index: modules/image/image.module =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.module,v retrieving revision 1.6 diff -u -8 -p -r1.6 image.module --- modules/image/image.module 21 Jul 2009 07:09:46 -0000 1.6 +++ modules/image/image.module 21 Jul 2009 22:26:59 -0000 @@ -790,17 +790,17 @@ function image_effect_apply($image, $eff function theme_image_style($style_name, $path, $alt = '', $title = '', $attributes = array(), $getsize = TRUE) { // theme_image() can only honor the $getsize parameter with local file paths. // The derivative image is not created until it has been requested so the file // may not yet exist, in this case we just fallback to the URL. $style_path = image_style_path($style_name, $path); if (!file_exists($style_path)) { $style_path = image_style_url($style_name, $path); } - return theme('image', $style_path, $alt, $title, $attributes, $getsize); + return theme('image', file_create_url($style_path), $alt, $title, $attributes, $getsize); } /** * Accept a percentage and return it in pixels. */ function image_filter_percent($value, $current_pixels) { if (strpos($value, '%') !== FALSE) { $value = str_replace('%', '', $value) * 0.01 * $current_pixels; Index: modules/image/image.test =================================================================== RCS file: /cvs/drupal/drupal/modules/image/image.test,v retrieving revision 1.5 diff -u -8 -p -r1.5 image.test --- modules/image/image.test 21 Jul 2009 07:09:46 -0000 1.5 +++ modules/image/image.test 21 Jul 2009 22:26:59 -0000 @@ -100,18 +100,33 @@ class ImageStylesPathAndUrlUnitTest exte $this->assertRaw(file_get_contents($generated_path), t('URL returns expected file.')); $generated_image_info = image_get_info($generated_path); $this->assertEqual($this->drupalGetHeader('Content-Type'), $generated_image_info['mime_type'], t('Expected Content-Type was reported.')); $this->assertEqual($this->drupalGetHeader('Content-Length'), $generated_image_info['file_size'], t('Expected Content-Length was reported.')); // Check that the URL points directly to the generated file. $expected_generated_url = file_create_url($generated_path); $actual_generated_url = image_style_url($this->style_name, $this->image_filepath); - $this->drupalGet($expected_generated_url); $this->assertEqual($actual_generated_url, $expected_generated_url, t('Got the download URL for an existing file.')); + + // Fetch the direct URL. + $this->drupalGet($expected_generated_url); + $this->assertRaw(file_get_contents($generated_path), t('URL returns expected file.')); + $this->assertEqual($this->drupalGetHeader('Content-Type'), $this->image_info['mime_type'], t('Expected Content-Type was reported.')); + $this->assertEqual($this->drupalGetHeader('Content-Length'), $this->image_info['file_size'], t('Expected Content-Length was reported.')); + + // Check that the direct URL supports private files. + variable_set('file_downloads', FILE_DOWNLOADS_PRIVATE); + $expected_private_url = file_create_url($generated_path); + $actual_private_url = image_style_url($this->style_name, $this->image_filepath); + $this->assertNotEqual($actual_generated_url, $actual_private_url, t('Private and public download URLs differ.')); + $this->assertEqual($actual_private_url, $expected_private_url, t('Got the private download URL for an existing file.')); + + // Fetch the direct URL using private files. + $this->drupalGet($expected_private_url); $this->assertRaw(file_get_contents($generated_path), t('URL returns expected file.')); $this->assertEqual($this->drupalGetHeader('Content-Type'), $this->image_info['mime_type'], t('Expected Content-Type was reported.')); $this->assertEqual($this->drupalGetHeader('Content-Length'), $this->image_info['file_size'], t('Expected Content-Length was reported.')); } } /** * Use the image_test.module's mock toolkit to ensure that the effects are Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.1013 diff -u -8 -p -r1.1013 user.module --- modules/user/user.module 21 Jul 2009 07:27:00 -0000 1.1013 +++ modules/user/user.module 21 Jul 2009 22:27:00 -0000 @@ -1175,17 +1175,17 @@ function template_preprocess_user_pictur $filepath = variable_get('user_picture_default', ''); } if (isset($filepath)) { $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous')))); if (module_exists('image') && $style = variable_get('user_picture_style', '')) { $variables['picture'] = theme('image_style', $style, $filepath, $alt, $alt, array(), FALSE); } else { - $variables['picture'] = theme('image', $filepath, $alt, $alt, array(), FALSE); + $variables['picture'] = theme('image', file_create_url($filepath), $alt, $alt, array(), FALSE); } if (!empty($account->uid) && user_access('access user profiles')) { $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE); $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes); } } } } Index: modules/user/user.test =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.test,v retrieving revision 1.47 diff -u -8 -p -r1.47 user.test --- modules/user/user.test 20 Jul 2009 18:51:35 -0000 1.47 +++ modules/user/user.test 21 Jul 2009 22:27:00 -0000 @@ -691,22 +691,41 @@ class UserPictureTestCase extends Drupal // Set new variables: valid dimensions, valid filesize (0 = no limit). $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); variable_set('user_picture_dimensions', $test_dim); variable_set('user_picture_file_size', 0); $pic_path = $this->saveUserPicture($image); - // Check if image is displayed in user's profile page. - $this->drupalGet('user'); - $this->assertRaw($pic_path, t("Image is displayed in user's profile page")); - // Check if file is located in proper directory. $this->assertTrue(is_file($pic_path), t('File is located in proper directory')); + + $this->drupalGet('user'); + $actual_style = variable_get('user_picture_style', ''); + $expected_style = 'thumbnail'; + $thumbnail_url = image_style_url($expected_style, $pic_path); + $this->assertEqual($expected_style, $actual_style, t('Default user picture style is %style.', array('%style' => $expected_style))); + $this->assertRaw(image_style_url($expected_style, $pic_path), t("Image is displayed in user's profile page.")); + $this->assertTrue(strpos($thumbnail_url, $expected_style), t('Image is displayed in expected style.')); + + // Check if image is displayed in user's profile page with automatic + // thumbnail generation is disabled. + variable_set('user_picture_style', ''); + $this->drupalGet('user'); + $public_url = file_create_url($pic_path); + $this->assertRaw($public_url, t("Image is displayed in user's profile page")); + $this->assertFalse(strpos($public_url, $expected_style), t('Image is displayed in its original size.')); + + // Check if image is displayed when using private files. + variable_set('file_downloads', FILE_DOWNLOADS_PRIVATE); + $this->drupalGet('user'); + $private_url = file_create_url($pic_path); + $this->assertNotEqual($public_url, $private_url, t('Private and public image URLs differ.')); + $this->assertRaw($private_url, t("Image is displayed in user's profile page")); } } function saveUserPicture($image) { $edit = array('files[picture_upload]' => realpath($image->filepath)); $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); $img_info = image_get_info($image->filepath);