ImageCache seems to be using incorrect paths. Here's what I'm doing (using public transfer, PHP 5.2.4).

  1. My path is set to sites/default/files
  2. Create an ImageCache preset called mypreset
  3. Create a content type and add an ImageField to it. Do not set a custom path.
  4. Set the ImageField to display using one of the "mypreset" options
  5. Add some sample content
  6. View the content

When I view the content, it merely says "Article Image" where the image should be. Now here's the src of the img tag it writes:

src="http://jw.local/sites/default/files/imagecache/test/tn-IMG_0967.jpg"

Which produces no errors, but if I paste that url into my browser, I get redirected to my home page. If I insert "sites/default/files" into it, I get the correct image, like so:

http://jw.local/sites/default/files/imagecache/test/sites/default/files/tn-IMG_0967.jpg

And then the image shows up when I refresh my site's home page. This seems to be a bug in ImageCache, because using the ImageField by itself makes the image appear correctly. However, the actual file resides in sites/default/files/imagecache/test (not sites/default/files/imagecache/test/sites/default/files).

I tried swapping out various versions of ImageAPI and ImageCache (1.3 to 1.6 for API, beta 8 to DEV for Cache) and none of that works. CleanURLs and Rewriting are working, and ImageCache can create subdirectories without problem. I tried in FireFox 3.5beta and Safari 3. I have also read the troubleshooting guide as well as a few threads on drupal.org, but there's nothing obvious that I can see. I have my drupal installation on a virtual machine, so if anyone wants me to change anything, it would be a snap to revert back to pre-ImageAPI/ImageCache setup.

Comments

JohnWoltman’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta9

Upon further investigation I have found that if I go to admin/build/imagecache and flush the cache, all the images will appear next time I load the home page. I have also found that if I change imagecache.module's imagecache_create_url() function to return the correct path then it seems to work. I haven't tested it much, but here's what I changed (just one line).

*** imagecache.module.backup	2008-12-26 01:03:56.095231202 +0300
--- imagecache.module	2008-12-26 01:07:12.782664303 +0300
***************
*** 312,318 ****
    $args = array('absolute' => TRUE, 'query' => $bypass_browser_cache ? time() : $bypass_browser_cache);
    switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
      case FILE_DOWNLOADS_PUBLIC:
!       return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
      case FILE_DOWNLOADS_PRIVATE:
        return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
    }
--- 312,318 ----
    $args = array('absolute' => TRUE, 'query' => $bypass_browser_cache ? time() : $bypass_browser_cache);
    switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
      case FILE_DOWNLOADS_PUBLIC:
!       return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. file_directory_path() .'/'. $path, $args);
      case FILE_DOWNLOADS_PRIVATE:
        return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
    }
JohnWoltman’s picture

Status: Active » Closed (fixed)

Fixed in beta 10.