A lot of people have complained about Imagecache not creating images in the correct folder, or the preview (imagecache_sample.png) doesn't work. Most likely these are individuals that have upgraded from a previous Drupal version, or fresh install with their old 'files' data directory.

Imagecache NEEDS the proper htaccess options. Older versions of Drupal do not have this and cause the module to act up. Before you drive yourself nuts and try implementing code hacks, try this.

1. Go into your 'files' directory (sites/default/files) and delete or rename your .htaccess file.

2. Login to your drupal site and navigate to the file system admin. (yourdomain.com/admin/settings/file-system)

Drupal will automatically create a new .htaccess file in your files directory once you visit the file-system admin page.

3. Verify a new .htaccess file has been created in your 'files' directory. It should now look like this:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

4. Now try imagecache, everything should work!

This issue is attributed to deprecated entries in your ../files/.htaccess file from older installations of drupal and not a bug in imagecache.


Carlos Miranda Levy’s picture

I had been at this for hours...
In my case, my .htaccess was missing the follow symlinks...

Barry Ramage’s picture

after trying several options..

Imagecache NEEDS the proper htaccess options WAS GOOD
enabled the Image API GD2 WAS GOOD
imagecache presets NOW SET WITH WIDTH AND HEIGHT

extra /directory-path-relating-to-content-type/ still in directory...

root directory .htaccess changed back to 'DirectoryIndex index.php' (site in place on top of exsisting html site)

lots of head scratching, still no change in imagecache, AGHHHH!

but, then, looked at image files...

changed 'm&d3891.jpg' to 'm-and-d-3891.jpg', deleted and re-uploaded the image in the node - Bingo Knickers! success!

(have had several issues with caches not clearing and database races, so, possibly the root along with the '/files' .htaccess are a factor in this case - just took a while to get to my browser)

Carlos Miranda Levy’s picture

Completely forgot about this and after about an hour trying to get it to work (uninstalling/installing/troubleshooting) decided to search, and found my own comment praising the fix :-)

marcofabian’s picture

I tried this solution but the preview files are still not created. One of my drupal sites imagecache module works fine but any other one I create, comes with this problem...

marcofabian’s picture

In my case, I enabled the Image API GD2

nofue’s picture

Thanks for all the hints, I want to add one more:
If the access rights on the various subdirectories are screwed (as it happens when you work in the file system using root access, f.e.), things may also go worse. If you have only FTP access to your webspace, this may not be an issue at all.


-- form follows function

Wouter.D’s picture

ImageAPI GD2 was the trick! Thnx!

BiggerBang’s picture

Tytest, you are a LEGEND! I have spent hours and hours trying to sort out an issue I thought was with Node Gallery, then with Imagecache, then file permissions etc etc etc.

Sending you good karma

Elijah Lynn’s picture

My preview wasn't working either (dead link) and the .htaccess was fine.

I just simply disabled ImageCache API GD2 and then reenabled and now it works!

The Future is Open!

Elijah Lynn’s picture

And then it stopped. Not sure what I did in the end but I did end up installing the transliteration module, I think that was it but not 100%. Maybe this helps someone in the future.

The Future is Open!

Elijah Lynn’s picture

It turns out that it was a permission issue. Somehow when a new preset gets created the permission does not get set. We are using Admin Role. Uninstalling and reinstalling the ImageCache API GD2 module must just set the right permissions. I would see this as a bug. I know this isn't the right thread for this.

The Future is Open!

bailey86’s picture

Disabling and then re-enabling the GD2 module meant that the thumbnails were working again.

lel’s picture

Thank you very much, Elijah! I was starting to pull out my hair trying to figure this out.

I have no idea why permissions would change when you create or edit a preset causing your images not to display or even to be created, but thank goodness there is a way to fix the permissions.

wOOge’s picture

@Tytest's Fix worked for me as well (Deleting the /sites/default/files/.htaccess — then rebuild the imagecache previews.) I didn't even need to visit teh /admin/file system — to start building imagecache previews.

Here are some keywords for someone searching for this next time:

imagecache GD2 not working
imagecache preview missing
imagecache preview not showing

wOOge | adrianjean.ca

dyesdyes’s picture

Use Tytest's fix work
Use clean URL
Enable GD2 on your server AND the module

It should work now.

robbertnl’s picture

Tytests fix doesnt work for me.
There's even no imagecache folder in my files folder

edsonmatos’s picture

See: http://drupal.org/node/134439

Do this if you use lampp:

1) Edit http.conf ==> /opt/lampp/etc

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

2) Now go to http://yoursite.com/?q=admin/settings/clean-urls, and run the test for "Clean URLs".

Then, select the radio button to set clean URLs to "enabled" and submit the form.


MacielDI’s picture

Indeed everything works after this!

audleman’s picture

After spending two days banging my head against the wall on this one I found the solution to my problem. I had read several times that I needed to install the ImageAPI GD2 module and tried that to no avail. Only now, after staring at it a dozen times do I see that I was installing 'ImageAPI' but not the item directly below it titled 'ImageAPI GD2'. So if you're retarded like me hopefully this note will save you a headache.

nghiadhcntt’s picture

Thanks 4 your contribution!
You saved my life :P

odedbobi’s picture

i was just about to start hacking the code.
thanks for saving me hours of hair pulling (don't have a lot left).

langrock’s picture

In case somebody is still watching this discussion. I had been trying to get ImageCache to work this weekend, albeit without success, hence this post. In my case, the .htaccess file was indeed different from what the standard listed above looks like, since we are using a WebAuth module. Nevertheless, I deleted the .htaccess file within the /sites/default/files folder and ImageCache started working, i.e. it created the sub directories within imagecache and also showed the preview for the presets. Before that, it simply would only create the imagecache folder and would put the sample image straight into the files folder and pretty much did nothing else. I was excited when it started working, but the moment the system created the new .htaccess file, things are back to where they were before. The previously generated images don't show up anymore and new ones are not being created on demand. The new .htaccess file looks exactly like the one listed at the top of the post, but I imagine that this is somehow getting in the way with the WebAuth module. If somebody smarter could give me a hint what I could try next, that would be great.

Thanks in advance,

UPDATE 4/12/2011: After changing the file transfer format to private, things seem to work. Not sure why public created so many problems.

algeorge’s picture

Hi I worked on this one for ages, some images showed, others didnt.

Using Ubuntu naming conventions are more flexible than Windows and this was the problem.
EG if filename of image was 857D+fixed.jpg it would not show under View or Preview, but would show under Edit.
If the same file was uploaded as 857D_plus_fixed.jpg then all worked as expected.
I hope this saves others heaps of heartache!!
Perhaps Drupal imagecache should have a naming convention check integral??

Albert Volkman’s picture

I'd just like to +1 this post. It saved me a lot of headaches. My particular instance was caused by an additional 'RewriteEngine off' line.

studgate’s picture

it works and solved my problem! Thanks

patoshi’s picture

ok so this has stumped me for the past 24 hours or so... so the story is that one of my clients sites was still on the old D6 Drupal 6 platform. I remember having this issue pretty often while working on D6 sites. Most of the time I think it had to do with permissions, but not all the time. This time it was really really weird.

- everything in my files directory is set at 777
- clean urls are activated and working
- Imageapi GD is turned on and working!
- File system is set as Public ...

Those are my settings. But when i create a new preset, it does not create the preset folder in files/imagecache/{preset} directory which results in a broken image. The interesting thing about this is if you create the preset folder manually and then click on "save preset" on your preset page, it DELETES your folder... i'm not sure why, but it deleted all of my images in imagecache preset folder.

Now the way it seems to work is changing the FILE SYSTEM setting to "PRIVATE"..... but the thing is i would like to figure out why public doesnt work.

Please reply back if you had the same problem and this change of file system to PRIVATE solved it for u!

keywords: imagecache images not showing up generating 2012