Hey everyone,

I've recently noticed a bug in the Imagecache filepath if the user ever changes the "File System Path" for the site (located at /admin/settings/file-system).

In our use case, we needed to change the file system path from the development server to the production server. Before using imagecache, we were able to handle this change with symlinks from the old files folder to the new files folder.

But once we use Imagecache, both the original file system path and the new file system path appear in the imagecache link to the image. Here's how the imagecache link looks once we change the file system path:

http://www.example.com/[newfilesystempath]/imagecache/[presetname]/[oldf...

As a result, the imagecache version of the image doesn't display. Flushing the imagecache preset doesn't seem to work either because imagecache does not seem to know to regenerate the image if the file system path to the original image has been changed.

Any ideas for how to fix this? I think it would be best not to hard code the file system path directly into the imagecache link.

Thanks,
Ben

Comments

Terko’s picture

Hello!
I had the same problem. I've made this query in PHPMYadmin to replace the path

UPDATE files SET filepath = REPLACE(filepath,"sites/default/files/","")

I am not sure yet if this will work. I am trying now to fix my site.

Terko’s picture

Yeah, that works!
But I can't fix the node images to show, only the imagecache thumbs.

Terko’s picture

After that is enough to delete the caches. And my site is fixed now. I've fixed 3 sites in this way when moving them from different installations to one installation of Drupal.

wolf4jc’s picture

Can you please help with how to run this query? When I put that string in phpAdmin and press Run Query, I get a message saying: You have to choose at least one column to display. Not sure what to do. Thank you in advance for any pointers here!

RagsToRich’s picture

Yes this is definitely an issue with imagecache. I have exactly the same problem on a test site I'm experimenting with.

I can get it working fine with the file system set to private, but set to public and it all goes haywire.

A google search shows that tons of people have problems getting imagecache to function correctly - this is probably one of the major causes.

RagsToRich’s picture

I take it back...

Fixed this by changing the chmod permissions of sites/default and all subdirectories so that public could read, and owner/group can read/write/execute.

victor.stan@gmail.com’s picture

Also, FYI i found this post to fix my particular problem: http://stackoverflow.com/questions/1578340/drupal-imagecache-not-working
particularly:

"Imagecache does not work when friendly url's are off. If this is the case, it can not 'find' the path to its folder in sites/default/files. When I turned them on, the folder with the name of the setting was created ok. The Imagecached images don't appear in here though. I'm putting it down to switching dev from Win to Mac, as a few people suggested on the Drupal forums. I'm hoping the issue will be fixed when I return back to a Win machine ... – stef Oct 18 at 16:03"

Oleksa-1’s picture

Summit’s picture

Subscribing, what is the best method for this please?
Having the same issue!
greetings, Martijn

srjosh’s picture

terko - #1 was totally the clue to my problem; thanks!

millionleaves’s picture

I used #1 after moving the files directory out of the site folder into root of the Drupal instance. This query should and would have done the trick except I then went and changed it again using a similar query. When I did this, I used /files as the replace string in the query rather than just files (no forward slash).

This created a problem where the correct derivative images were being generated by imagecache, but the displays weren't working. When I looked at the paths with firebug, I found the path looked like this:

http://mysite/files/site/imagecache/fp_centre_carousel/%252Ffiles/centres/carrousel_2.png

That %255F was caused by the leading /files in the filepath for the original image in the database. When I did another replace query, this time replacing "/files" with "files" the problem was fixed.

Solution came from this page: http://drupal.org/node/1270376

fizk’s picture

Issue tags: +ImageCache 2.x Todo

Marking as ImageCache 2.x Todo.