Troubleshooting Imagecache
Imagecache module reformats and serves uploaded images according to default and user-defined settings. When the images are called by Drupal, imagecache serves them up by spec, and makes a copy of the file which it saves in the sites/default/files/imagecache folder. So, if you want a file to be displayed at 250 pixels width (no matter the dimensions of the original file) you can specify a setting in imagecache and it will display files according to these specs. Very handy for use with views, display suite, etc.
Unfortunately, there are a lot of ways this can go wrong, and I've experienced a lot of them. Hence this quick checklist. If you've untied any other imagecache knots, please share, and save us all some frustration!
Path to imagecache files must be writeable by user.
The first time an un-cached image is called by Drupal, imagecache reformats it, sends it to the screen, and saves the modified file to a directory (something like: sites/default/files/imagecache/imagecache_format/cachedfile.jpg.) If Drupal doesn't have permission to write to that folder, you'll have problems. Make sure the sites/default/files folder and its subdirectories are writeable.
API enabled?
Imagecache relies on an API to do its work. It won't work by itself. Make sure you have one enabled.
Path settings
Check to make sure that your file path is set properly in admin/settings/file-system and that the download method is set to public.
Also make sure that the correct base path is specified in settings.php.
You can verify that Drupal can load an image file directly by navigating to mysite.com/files/filename.jpg. If the file doesn't appear here, the problem may not be with imagecache.
.htaccess and RewriteEngine
Imagecache requires the rewrite engine to work. Make sure that .htaccess is present and available to the server. If .htaccess isn't allowed by the servert, include the following code in your Apache configuration:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Spaces, "&" and "#" in filenames
Uncommon characters in image file names can mess with the rewrite engine. Change filenames so they contain only standard characters (numbers, letters and underscore).
Memory
Files which are large in terms of pixel dimension and depth of color (not necessarily file size) may require more memory than PHP makes available. If larger images are not being processed, try increasing available memory in PHP (try searching in php.ini for memory_limit, and increasing the memory available to php scripts).
Well, that covers most of the problems I've run into with imagecache and I hope it helps you out of a bind. If you encounter other problems (and their solutions!) please post them here!



Post new comment