Hi, I'm after a bit of help. I've created 2 presets, but the folders aren't actually being created in the file system. The images I upload are being placed in the /sites/default/files folder, but when I try and view the file directly (eg, http://site.com/sites/default/files/image.jpg) I get a 404 not found.

Does anyone know what the problem might be?

Thanks in advance.

CommentFileSizeAuthor
#83 i2.PNG10.09 KBbensquare
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kidsleep’s picture

JBoo,
Are you sure you have the correct permissions on the files folder? On the status screen does it show any actionable items?

ecstasy2’s picture

I am having the same issues

Cybso’s picture

Same here (PHP on IIS). No failure in logs. Permissions are ok, uploads are possible.

nravens’s picture

I've found that setting your file system to Private rather than Public, makes it work... but it affects other modules so not ideal solution.

So the issue should be about getting imagecache to work with the public file system.

Jboo’s picture

I'm sure I tried changing the permissions to start with! However, I've just changed the files folder to 0777 permissions and now it works. Should it be 0777 or some other setting?

Thanks again.

leenwebb’s picture

I am having this problem as well -- the files are being uploaded (and the thumb images created for display on the edit page) but no files are being created for the presets inside the imagecache folder. All files/folders are 777, the tmp folder is 777, the php.ini limit is very high (and I've never had any imagecache problems on this server with D5), and I am stumped. I have the latest ImageAPI and am using GD (not imagemagick).

Setting the file system to private works, but is wrong for my site for many other reasons.

nravens’s picture

Refer to http://drupal.org/node/366177

I haven't tried it yet but will try when I get a chance later today...

drewish’s picture

Component: imagecache_image module » Code

Okay so I'm guessing you've all don't have clean URLs and your doing public file transfers. Or am I wrong?

rubenv-1’s picture

I am having this problem also, with the settings drewish described in comment #8 (No clean url + public file transfers).

drewish’s picture

Title: No Imagecache folders and can't view images » Without clean URLs ImageCache doesn't create folders or images
Category: support » bug

right... currently the module requires that you either have clean urls or private files. i'm working on a patch but the current workaround is to use private files.

drewish’s picture

marked #446470: Folders not being created as a duplicate.

drewish’s picture

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

marked #359387: broken preview on presets as a duplicate.

ragavendra_bn’s picture

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

Thanks Jboo. for comment #5

After adding a new preset to add text on images was added to product_full the default preset. Few images never got copied to .imagecache/product_full. Your trick to make 777 helped imagescopy after preset on product_full default preset folder for 6.x-2.0-beta9.

#5
Jboo - March 27, 2009 - 10:58

I'm sure I tried changing the permissions to start with! However, I've just changed the files folder to 0777 permissions and now it works. Should it be 0777 or some other setting?

Thanks again.

firstov’s picture

running Drupal 6.12 with ImageCache 6.x-2.0-beta9. Getting 404 error and default home page in the browser when trying to access my_site.com/sites/site_name/files/imagecache/w_mark/imagecache_sample.png?1243474171 URL. (the URL to verify configuration of one of my presets I setup. Actually none of the presets work
Tried to set permissions to 777 for imagecache folder with no effect.
When tried to disable rewrite_engine=off directive in the files/.htaccess file, gotten Permission Denied error (since imagecache folder was empty and no index file was in there).
PHP 5.1.6 running on CentOS5. Any hints would be appreciated. Clean URLs are enabled.
"Private Files" is not an option for my site.

Please help! Thanks.

firstov’s picture

just replying with more updates.
On the troubleshooting guide it says:
....
make sure the .htaccess file under your files directory contains exactly these two lines (no more no less):
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options +FollowSymlinks
.....
that's what made mine installation of imageCache to work just fine.

ball.in.th’s picture

Hi,

I do have clean URLs enabled and public file access method. sites/default/files also has 777 permission.

However, after installing beta9, I tried to test my first preset and got 404 error (http://ball.in.th/sites/default/files/imagecache/test/imagecache_sample....). Then I checked sites/default/files and couldn't find imagecache directory at all. Am I missing something? I also tried disabling and re-enabling the module again; still got no imagecache directory. I did exactly the same thing on my windows box at home and it worked fine; but not on this Linux server.

My .htaccess in sites/default/files have these lines:
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

The "Options None" is not on the Troubleshooting page. Does it matter?
Also, I've noticed that the last new line character is missing in the .htaccess in sites/default/files. That is, the last line doesn't have a new line character (\n). Is this related?

Please help. Thanks.

Sinan Erdem’s picture

I had Clean URLs and all file permissions was 777. But image cache wasnt working. Then I tried this about .htaccess file as mentioned at comment #15. Now it works!

Thanks...

Sinan

ball.in.th’s picture

Continuing from my previous comment. A visit to admin/reports/status did create directory "imagecache" in sites/default/files (a message's shown on this page). However, it's empty. Creating a new test2 preset didn't help; still got 404 error (http://ball.in.th/sites/default/files/imagecache/test2/imagecache_sample...).

I've also tried removing "Options None" from .htaccess in sites/default/files and test with a new preset. That didn't work either.

Btw,

What could be wrong with my config?

ball.in.th’s picture

Updates for my issue:

It turns out my hosting provider has a kind of setup that uses lighttpd, instead of apache, to serve image files. That's why a request to "nonexistantfile" returns a Drupal "page not found" error and to "nonexistantfile.jpg" returns a 404 error. I've asked my hosting to disable lighttpd and now ImageCache is working great!!

Also, my .htacess has these three lines and doesn't seem to cause any problem.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

PS. I used LiveHTTPHeaders to check the reply headers to realize that it's coming from lighttpd.

sfdrummer’s picture

Well, I was having an awfull time trying to get this to work as I'm developing a site on a Shared IIS server. I had to resort to an ugly hack to get it to work properly:

Replace this:

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  $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);
  }
}

With this:

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  $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'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
    case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
  }
}

Then surf through all the images on your site so that the images are generated. Then turn it back, now all my images work fine.

Like I said, its ugly but there you go...

schedal’s picture

Nothing worked, after 4 hours of trouble shooting:

1. Private vs public files, /tmp folder access correct
2. 777 permissions on files folder
3. uninstalled modules, re-added in single (correct) order
4. modified files/ htaccess file with over 4 different permutations
5. modified root htaccess file with RewriteBase on and off
6. tried manually creating folders

In my case, nothing could make the folder "imagecache" be created, or if I manually made it: for the files to be generated.

SOLVED by manually over-riding the function "imagecache_create_url" as per post #20 above.

I should note that I am on Apache not on IIS; my server is virtual and shared.

THANK YOU!!

I really hope that no one else will have to suffer as long a painful trouble shooting process as this as I just did...

Kindly,

Sebastian.

snowbbdd’s picture

THANK!!!!! YOU!!!!!

nestor718’s picture

Please Note: This only works for windows server, IIS configuration with no clean URL's.

Hello guys! Not sure if this is 100% but it seem to work okay and builds on #20 code by actually testing if the file is really in the directory first right up in the public downloads select method. I've done a similar module for an ASP.NET project that checks a directory first for a file and if it didn't find it, it will generate on the fly.

I'm not sure what the big deal is about "clean" URL's but why would you need that to see if a file is at a given path anyway? On to the code

replace this:

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  $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);
  }
}

With this:

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = NULL) {
  $path = _imagecache_strip_file_directory($filepath);
  if (module_exists('transliteration')) {
    $path = transliteration_get($path);
  }
  $query = $bypass_browser_cache ? time() : $bypass_browser_cache;
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
    if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . file_directory_path() .'/imagecache/'. $presetname .'/'. $path)) {
        return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $query, NULL, TRUE);
    } else {
        return url('system/files/imagecache/'. $presetname .'/'. $path, $query, NULL, TRUE);
    }

    case FILE_DOWNLOADS_PRIVATE:
     return url('system/files/imagecache/'. $presetname .'/'. $path, $query, NULL, TRUE);
  }
}

There is a check there to see if the file is there or not. If it is, then the standard URL will be given, otherwise, the 'system/files/imagecache' path is invoked thereby generating the file. Other URL's will be unaltered.

About my sytem:

IIS 6
PHP 5
vbDrupal 5
No clean URL's (don't want to fork over the loot for the ISAPI rewrite)
Public downloads

Thing is, #20 hacks will always regnerate the files from one user location to another because the 'system/files/imagechace' path is always invoked (and none existent) so the files will always be regnerated. So we need to check if they are there and only generate if we need to. I think that's what imagecache was supposed to do, right? :)

csc4’s picture

I've been at this for 14 hours - and the change at #20 http://drupal.org/node/410200#comment-1709746 and then editing and saving (no changes) each of the presets has solved the problem for me too.

Specifically line 315 imagecache.module:
return url($GLOBALS['base_url'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);

I have previews again!!

IIS server

Anonymous’s picture

I don't know anything about all these codes. Per the code post in #20, is it necessary to replace it with the original once done?

This is the only solution I've found that solves my nightmare with this issue. But it only works if I leave the code from #20 in place. The moment I revert back to the original code, all images are no longer displayed again.

jicidre’s picture

Version: 6.x-2.0-beta9 » 6.x-2.0-beta10

I suscribe to comment #20
* Files directory with 777 access rights
* Clean URL in private
* imagecache and preset folders present.
* Using Drupal 6 on Apache and Linux.

The fix was to change the code as instructed in comment #20.
Note, the code on my 6.x-2.0 version was slightly different
You can see the commented and new files here

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  if (module_exists('transliteration')) {
    $path = transliteration_get($path);
  }

  $args = array('absolute' => TRUE, 'query' => empty($bypass_browser_cache) ? NULL : time());
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
     
      /*return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);*/
      return url($GLOBALS['base_url'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
    
   case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
  }
     
joachim’s picture

I can confirm that code from #26 fixes the problem for me on a Zeus server.

thethanghn’s picture

I've tried #20.

- success in uploading files
- Fail in viewing image through jQuery modal dialog (this dialog represent binary data, not the image

#26 result in an error in file common.inc :(

mtpultz’s picture

I'm having the same problem as you exactly. Some people are having things happen that are similar but yours is it exactly. What did you do to solve this? I tried all the .htaccess solutions and nothing. Haven't tried setting it to private as I don't know what will happen to the site if I did and I'm using clean urls.

mtpultz’s picture

I had the same luck as Sebastian did... and unfortunately the same suffering

hanoii’s picture

I think this is a duplicate of #241541: wrong url from imagecache_create_url() when no clean urls + public downloads, which is an old issue with a reported problem for D5, but the problem is current for D6.

Have a look at my patch in #21 of http://drupal.org/node/241541#comment-2118354 and comment if that fixes the problem in this issue. I'd think it should.

wayne247’s picture

I had almost the same issue as everyone else.

- Linux / Apache
- Drupal 6
- Ubercart 2
- ImageCache beta 10
- Clean URLs are enabled
- Files are set to private (i sell downloads, so quite mandatory)

When I was logged in as administrator, everything worked fine.

When I logged out as visited as guest, no images. I'd get a question mark in safari, blanks in firefox.

I went in imagecache.module, where posts #20 and #26 target, but went a different route. I took the line under the case "private files" and copied it over the case for "

See the final output of my function, with the original line commented out:

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  if (module_exists('transliteration')) {
    $path = transliteration_get($path);
  }

  $args = array('absolute' => TRUE, 'query' => empty($bypass_browser_cache) ? NULL : time());
  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($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
      //return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
  }
}

and then BAM! images are there. Thanks to everyone for individual posts about their problems and how they fixed it. I'm adding my contribution to the lot in case someone has the bug I have.

There seems to be so many different configurations that no two person ever have the exact same bug.

paljsingh’s picture

I too confirm.. #20

Apache/2.2.12 (Ubuntu)

No Clean URL, Public View

-Jitender Pal Singh

ndmaque’s picture

i go with #20 - a dirty hack but needy
it drove me mad so i quickly wrote a jquery url changer as it seems better than a core hack.


 $('img.imagefield-field_photo').each( function() {
   
   var new_src = $(this).attr('src').replace(/shop_photos/,'shop_thumbs') ;
   $(this).removeAttr('width') ;
   $(this).removeAttr('height') ;
   $(this).attr('src', new_src) ;
 
 });

but decided to hard code it as first time visitors had problems

a little safer like this just in case they upgrade server or you upload your hacked imagcache.module to another site?

there's a value in variable table that tell us: variable_get('clean_url', 0)

<?php

    case FILE_DOWNLOADS_PUBLIC:
    if( variable_get('clean_url', 0) ) {   
      return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args) ;
    } else { 
      return url($GLOBALS['base_url'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
    }
?>

thanks for all your help

daveplml’s picture

Edit: OK, so after playing around yet MORE with this module, here is what was necessary:

1. Enable Clean URLs
2. Make edits as above (not quite sure if #20 or #26 was required, but one of them seemed to work)
3. Manually create directories
4. chmod (set permissions on) directories to 777

Still, a lot of work and frustration went into this... I appreciate everyone's support, and really hope that in the future, this is running w/o so much trouble.

Most of all, lest it be forgotten, thanks for writing the module - it IS helpful - it's just a little rough around the edges.

Originally:

Giving up...

After playing with this for far too much time, I have to throw in the towel. I'm not an advanced Drupal admin - a medium-level user - and can't get this figured out.

My images just aren't showing, and the directories aren't being created. Is anyone working on a patch for this? I'm afraid to spend more time on this - hacking apart PHP files just isn't a good use of time!

Sorry for the frustration, hoping this gets fixed in a real release!

suedehead’s picture

After hours and hours of pulling my hair out I've come to a solution - update ImageAPI to 6.x-1.x-dev. Everything works, no need to do the #20 or #26 solutions (which didn't work for me anyways).

byronveale’s picture

I know it's already been said a ways back, but setting file system/download method to "private" worked for me...

brisath’s picture

Subscribing

Set file system to private not solving the problem.
Upgraded ImageAPI to 6.x-1.x-dev not solving the problem

hanoii’s picture

@brisath: What about trying out the latest patch (#24) in #241541: wrong url from imagecache_create_url() when no clean urls + public downloads, would that solve your problem?

a.=

Bilmar’s picture

subscribing

botris’s picture

Confirming that #241541 fixes this problem for IIS without clean urls

schedal’s picture

BTW, in case this helps anyone, I had this issue again on a newly freshly-installed Drupal system [yesterday], and nothing worked except uninstalling imagecache, and then reinstalling it again... and then it worked! Oddly Imagecache was creating the folders for the presets, but not any of the image files in it; checked permissions etc. Anyways, just thought I'd mention it in case this helps someone else along the way to success...

cpapaya’s picture

I have tried all the above advice. Nothing has worked. I recently upgraded to Drupal 6 with the 6.x2.0 imagecache update
When I changed the code as suggested in #20 & #26 it created a new folder named /system/files but did not actually create the folder systems so an image was being called that was not there.
The problem to begin with for me, was that I was not seeing new images. Old images were fine. Discovered that a new folder was being created within the files folder called files. So drupal/files/files/imagecache
However, when i changed the admin>settings>file-system to files/files
I was unable to see any photos for the newly uploaded photos, just a box with an x. And, of course, I was not able to see any old photos as they are filed in files/imagecache

What should I do?
I've tried the advice in this node. I've also tried adjusting the imagecache_module line 555 as mentioned in node http://drupal.org/node/392100
My permissions are set to 777 - did not help
I've tried setting to private download - did not help
I tried changing the code in imagecache_module.
I've reinstalled imagecache, fieldfile, imageapi, and imagefield 3 different times & ran /update.php

Please - I need to fix this.

JavierGL’s picture

Hi!
My case solved..

System:
Drupal 6.14
Imagecache 6.x-2.0-beta10
ImageAPI GD2 actived
Public files with clean url
IIS

Solved:
- Preview and generate folder - Change imagecache.module line:

   case FILE_DOWNLOADS_PUBLIC:
    return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args); 
  

replace with this (like #20) http://drupal.org/node/410200#comment-1709746

    case FILE_DOWNLOADS_PUBLIC:
     return url($GLOBALS['base_url'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
  

- Generate image in frontoffice:
edit httpd.ini :

       RewriteEngine on
       RewriteBase /
       RewriteRule /sites/default/files/imagecache/(.*) /index.php?q=sites/default/files/imagecache/$1 [L]
   

Now all work!!!!

limazita’s picture

I am trying to run the drupal + ubercart on Mac OS X 10.5

My config is :
drupal 6.15
imageCache imagecache-6.x-2.0-beta9
no clean URL

Solution #32 works best for me so far, I can see the thumbnail images and I can click open the image to see a larger version of it. With solution #20 & #26 when I click to get a larger version of the image, the viewer opens with a bunch of code displayed.

With solution #32, when I try to add a new product, it takes a long time to upload the file (localhost) and I get the following error :

{ "status": true, "data": "\x3cdiv id=\"edit-field-image-cache-0-ahah-wrapper\"\x3e\x3cdiv class=\"form-item\" id=\"edit-field-image-cache-0-wrapper\"\x3e\n \x3cdiv class=\"filefield-element clear-block\"\x3e\x3cdiv class=\"widget-preview\"\x3e\x3cdiv class=\"imagefield-preview\"\x3e\x3cimg src=\"http://localhost/~Ao/sites/default/files/imagefield_thumbs/IMG_2575_Soph...\" title=\"IMG_2575_Sophrolaeliocattleya_JungleBeauab.jpg\" /\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"widget-edit\"\x3e\x3cinput type=\"hidden\" name=\"field_image_cache[0][fid]\" id=\"edit-field-image-cache-0-fid\" value=\"7\" /\x3e\n\x3cdiv class=\"form-item\" id=\"edit-field-image-cache-0-data-alt-wrapper\"\x3e\n \x3clabel for=\"edit-field-image-cache-0-data-alt\"\x3eAlternate Text: \x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"80\" name=\"field_image_cache[0][data][alt]\" id=\"edit-field-image-cache-0-data-alt\" size=\"60\" value=\"\" class=\"form-text imagefield-text\" /\x3e\n \x3cdiv class=\"description\"\x3eThis text will be used by screen readers, search engines, or when the image cannot be loaded.\x3c/div\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"edit-field-image-cache-0-data-title-wrapper\"\x3e\n \x3clabel for=\"edit-field-image-cache-0-data-title\"\x3eTitle: \x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"500\" name=\"field_image_cache[0][data][title]\" id=\"edit-field-image-cache-0-data-title\" size=\"60\" value=\"\" class=\"form-text imagefield-text\" /\x3e\n \x3cdiv class=\"description\"\x3eThe title is used as a tool tip when the user hovers the mouse over the image.\x3c/div\x3e\n\x3c/div\x3e\n\x3cinput type=\"hidden\" name=\"field_image_cache[0][list]\" id=\"edit-field-image-cache-0-list\" value=\"1\" /\x3e\n\x3cinput type=\"submit\" name=\"field_image_cache_0_filefield_remove\" id=\"edit-field-image-cache-0-filefield-remove\" value=\"Remove\" class=\"form-submit\" /\x3e\n\x3c/div\x3e\x3c/div\x3e\n\x3c/div\x3e\n\x3c/div\x3e\x3cscript type=\"text/javascript\"\x3ejQuery.extend(Drupal.settings.ahah, { \"edit-field-image-cache-0-filefield-upload\": { \"url\": \"/~Ao/?q=filefield/ahah/product/field_image_cache/0\", \"event\": \"mousedown\", \"keypress\": true, \"wrapper\": \"edit-field-image-cache-0-ahah-wrapper\", \"selector\": \"#edit-field-image-cache-0-filefield-upload\", \"effect\": \"fade\", \"method\": \"replace\", \"progress\": { \"type\": \"throbber\" }, \"button\": { \"op\": \"Upload\" } }, \"edit-field-image-cache-0-filefield-remove\": { \"url\": \"/~Ao/?q=filefield/ahah/product/field_image_cache/0\", \"event\": \"mousedown\", \"keypress\": true, \"wrapper\": \"edit-field-image-cache-0-ahah-wrapper\", \"selector\": \"#edit-field-image-cache-0-filefield-remove\", \"effect\": \"fade\", \"method\": \"replace\", \"progress\": { \"type\": \"throbber\" }, \"button\": { \"field_image_cache_0_filefield_remove\": \"Remove\" } } });\x3c/script\x3e" }

indepUser’s picture

Hi,

I had a working site on my local machine (imagecache was working). Then, I had to transfer the site to my hosting provider. In order to do that, I had to turn off clean URLs. And that's when the problem started. On my hosting provider, imagecache has stopped working. It is not creating any preset directories and not creating any image files in preset directories that existed from before. I have since enabled clean URLs but imagecache is still not working. How can I get it to work? Please help.

Thanks!

5n00py’s picture

I have same ploblems )
Image cache do not create any files or dirs in /sites/default/files/imagecache
But i find this line in the my httpd.log

[Tue Feb 02 14:48:11 2010] [error] [client 192.168.0.103] File does not exist: /var/www/html/home, referer: http://192.168.0.104/~sushi/?q=node/156

Why "/var/www/html/home" ?!
My apache configured to /home/*/public_html via userdir

CleanUrls are disabled.

TY.

fender-dupe’s picture

which file should i change??

YK85’s picture

hello, I was wondering if there has been further progress towards a permanent fix? thanks!

fender-dupe’s picture

nothing!!!

After 2 months my site is still not working. And I was blocked on ubercart forum beause I complained how bad support is and how bad ubercart is.
I can't beleive it, they just block anybody that complains. I asked the same questions 5 times, no answers!!

Horrible, ubercart is making drupal look so bad!!!

Oleksa-1’s picture

http://drupal.org/node/241541#comment-2516554 this patch solves "clean url" problem with new folders creation

YK85’s picture

ball.in.th’s picture

Not sure if this is the right place, but imagecache wasn't working on a restore of a website on my windows desktop. imagecache has been working fine on the real server -- the source of the restore. I've accidentally found that visiting admin/settings/file-system page caused "The directory /tmp has been created." message to appear. And after that imagecache is working fine on my windows box too. ^^

spikesagal’s picture

#24 is the cleanest solution. Thank you!

Sasuke_cub’s picture

Title: Without clean URLs ImageCache doesn't create folders or images » ImageCache With clean URLs doesn't create images
Priority: Normal » Critical

Hi.

I have run Drupal 6.16 on Apache 2 with Windows XP.

My problem is that ImageCache doesn't create the images of the new preset. Only show the images have a dimension of 100%x100% if I reduce the size it doesn't show them in a thumbnail for example.

I hope you can help me guys.... Thanks

hanoii’s picture

Title: ImageCache With clean URLs doesn't create images » Without clean URLs ImageCache doesn't create folders or images
Priority: Critical » Normal

@Sasuke_cub: I am not sure if your issue is related at all to the one discussed in here, it seems not as you changed the title for an opposite thing, which is not the proper thing to do on this issue queue, otherwise, it will loose track of the main problem.

I'd recommend you to create a new support issue asking for your comment and detailing your problem as it seems like something different.

samc’s picture

Subscribing.

I built out some new imagecache-based site features on my desktop (Mac/MAMP), and they work fine there, but they won't work up on the live server (Linux).

I've tried all the various hacks to the imagecache_create_url function, but none of them change the fact that the folder structure under files/imagecache isn't being created on the fly, and even when I manually create it, chown to apache and chmod 777, the images still aren't being created.

Apache 2.2.3
PHP 5.1.6
CentOS 5.2

FWIW, my desktop situation is Apache 2.0.59 w/ PHP 5.2.6 on OS X 10.6.

UPDATE: In the end my issue turned out to be user error. Additional error logging would have helped me greatly, so I created the following issue and patch #785522: Generate error when image can't be opened

schedal’s picture

With all due respect Hanoii, this problem has occurred now on three different websites, and all three of them had CLEAN urls. So I am not sure why the issue was changed to be only for non-CLEAN ones...???

hanoii’s picture

@schedal: I see your point. I only restored back the original title, because even though you are informing that you have problems with your imagecache installation with clean urls enabled, the comment #55 seems like a totally different issue, or is that same thing what's happening to you? I was once on top of this issue but now I lost track of it, specially because the patch provided by me back then and later slightly modified all seemed to work for me. So I wonder if your issue is really a problem in the create_url function or something completely different from what's discussed here? have you tried any of the patches/solutions described in this issue? I have numerous sites in D5 and D6 all with imagecache working fine. (And all with clean URLs).

I was only suggesting to keep this issue related to the discussion in fixing the create_url function which does have a problem for non-CLEAN URLs. Unless your issue with clean urls is actually part of this same problem, I think it's better to follow that in a separate issue. Do you get any error?

Sasuke_cub’s picture

Hi, I fixed my issue with this comment.

I hope it helps.

monteco’s picture

If you don't want to hack the module like #20 and #23, an annoying but effective workaround is to upload the images in the "private" file-system setup and then switch back to "public." This makes them load correctly, it just means having to switch back and forth every time you want to upload an image. It only works if you don't need a private file system.

marina_v’s picture

IIS server, drupal 6.15, Clean URLs enabled. Same issue was solved thx to post #20.

eforth’s picture

I can't believe! Thank you very much!

Using solution on #20

Drupal 6.17 running on IIS6 with Public Downloads and Clean URL OFF

nx7208’s picture

It takes about 2 hours to find solution.
Using solution on #20.
openpublish-2.1-build119.

Jenechka’s picture

Assigned: Unassigned » Jenechka

#20 sfdrummer

Awesome!!! it solved my problem. Just copy-paste.

PS drupal was in Lighttp

delboud’s picture

Upgraded ImageAPI to 6.x-1.x-dev solved the problem after 2 days of pulling my hair out...

pivica’s picture

Solution from #20 worked with latest imagecache dev version. Thanks!

math-hew’s picture

#20 solved the issue for me. Drupal 6, IIS6, ImageCache 6.x-2.0-beta10, ImageAPI 6.x-1.8.

ikeigenwijs’s picture

subscribe, all the same problems as above.
tried everything except all the coding hacks

In all despair i used the #20 solution, and it worked jipie!
What i m wondering about, considering the age of this tread and the age of the problem i assumed that this function would be edited in a dev months ago.
Is there any reason this is not a standard implemented solution?

rikimaru0007’s picture

@ post #20
Works with Drupal Version 6.19 and imagecache 6.x-2.0-beta10

That code is in sites/all/modules/imagecache
in file "imagecache.module"

CTRL+F and then enter "function imagecache_create_url"
(^,...,^)

I don't know why Clean-URLs are greyed out if you create another website(non-root domain) in same webhost...

Thank you very much sir. I know nothing at all about your code but I'm glad that you created a solution.

Anonymous’s picture

I think I just fixed this error once and for all. Do I get some sort of points for this if it's good?

Posted over here: http://drupal.org/node/764056#comment-3377104

Basically, if you are using a private filesystem with beta10 you *must* set your filesystem to be outside the drupal root folder and use the full system path in your "file system" settings under site configuration.

Either that, or roll back to beta9.

rmmcclay’s picture

Issue tags: +imagecache, +multi-site, +path

@ #20 had the clue I needed. Thanks sfdrummer.

My problem was on a multi-site installation of Drupal (6.19).

My setup is standard:

Linux/Apache

File system location:
/sites/somedomain.com/files

Used the standard/default .htaccess file, a copy in the root
of the Drupal installation and one in the /sites/somedomain.com directory

.htaccess under files is correct:

--
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks
--

No symbolic links used.

ImageAPI and GD2 correctly installed and activated.

Clean URLs on.

Public uploads on.

All file and directory permissions OK.

* * *

On the default site, imagecache worked fine. But on any of the virtual
host sites, the path was incorrect. imagecache was not creating the present
name directory under files/imagecache. Uploads would result in thumbnails
being put in imagefield_thumbs, and the preview of the present using
imagecache_sample.png wouldn't work. And the link would be broken on the page
where the thumbnail was supposed to be displayed.

I discovered that if I turned Clean URLs off, imagecache would work. But I want
Clean URLs.

The solution was as described:

Changed "file_directory_path()" to "'/index.php?q='"

Around line 321 in imagecache.module (version 6.x-2.0-beta10):

Before:
return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);

After:
return url($GLOBALS['base_url'] . '/index.php?q=' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);

Now imagecache is working with clean URLs on a multi-site installation.

Maybe there's a better solution, but I didn't want to mess around with fancy mod_rewrite or PHP work-arounds.

screener’s picture

#20 worked for me, what a relief.

DevElCuy’s picture

#20 worked for me too, I'm using Drupal 6.19 and have a multisite environment.

drupal_acc’s picture

#20 corrected an issue with WYSIWYG image upload failing to display pictures under a public file system.

http://drupal.org/node/980160

Reverting the code will break the module.

Rosamunda’s picture

Status: Active » Reviewed & tested by the community

Yay! After trying all ... #20 worked for me too!
I´m setting this as reviewed and tested, because several people have already say it worked, so I think it the patch should get to commit, don´t you?
Thanks!!
Rosamunda

Andrey Zakharov’s picture

For nginx as a frontend server, add to vhost config:

  location / {
      try_files      $uri  $uri/  @drupal;
  }
# ADD THIS BELOW
  location ~* /files/imagecache/ {
    # assume a clean URL is requested, and rewrite to index.php
    if (!-e $request_filename) {
        rewrite  ^/(.*)$  /index.php?q=$1  last;
        break;
    }
    error_page 404 = @drupal;
  }
# END ADD

where @drupal is location of backend proxing.

riverrat’s picture

Thank you
After days thinking that I was the most stupid person in the whole world I can now display photos.
I know it is not perfect but at least I can concentrate on the more difficult things on the site.

verta’s picture

+1 for #20!

This one was driving us nuts. It would be great if we could please add this to a dev release so we don't lose the fix on the next beta.

verta’s picture

Issue tags: +Clean URLS

(adding a tag for clean URLs)

verta’s picture

Hi,

We are seeing an extra question mark added at the src in the img tag when using imagecache in a view. This is causing broken links, any idea what could be causing this? (We are using it on a profile picture in a custom field, specifically so we could use imagecache.)


<img width="102" height="141" class="imagecache imagecache-presetname" title="" alt="" src="http://oursite/index.php?q=sites/default/files/imagecache/presetname/profile_pictures/10450.jpg?">

We have applied the patch in #20.

verta’s picture

Just to elaborate, we do not have clean URLs and it is not a private file system.
Still having this problem.

bensquare’s picture

FileSize
10.09 KB

I had the same problem and after spending a day , I found the problem was because imagecache was unable to create image in the tmp folder

How to resolve it ?

1) create a tmp folder in sites/yourwebsite/files/tmp
2) set it to 777
3) in site configuration -> files system-> setting
change the tmp folder from /tmp to sites/yourwebsite/files/tmp
4) save

And then it should work

if not, check the recent log entries: my log:

ImageCache already generating: sites/xxxxxxx/files/imagecache/featured/choc.jpg,
Lock file: /tmp/featuredchoc.jpg.

Eventually, I change /tmp to the sites/xxxxx/files/tmp and problem fixed

hope this helps. Merry Xmas

Ben

kix’s picture

Assigned: Jenechka » Unassigned

Can someone give me the path for the #20 change? I am a new Drupal user and don't know where the file is that I need to make this change.

bensquare’s picture

I think you can get it working without using the patch @20

if you post the error log here, it will be easier for others to see what the problem is and help you.

reports -> recent log entries (find the one related to imagecache)

amirtaiar’s picture

No Clean-URL
Drupal 6

#20 is working grate for me!
I didn't really understand what should I do when converting to the real domain and then clean-url.
Thank you

verta’s picture

I think #20 is not really a solution, because you have to hack the module, surf all of your pages that might have imagecached images on them, then unhack the module.

I don't think RTBC is really the right status for this issue, as a result. Would "active" be appropriate? "Needs work" maybe?

droshani’s picture

This problem still persist and the second part of the #34 solution fixed my issue >>> variable_get('clean_url', 0)

I used that in /sites/all/modules/imagecache/imagecache.module

System:
A VPS Windows 2008 server (IIS)
Drupal 6.20
Imagecache 6.x-2.0-beta10
Public files
Clean URL not supported so it is turned off.

Thank you

chaiwei’s picture

Status: Closed (duplicate) » Reviewed & tested by the community

Just replace the :
'/' . file_directory_path()

to :
url(file_directory_path())

it will works for NO CLEAN URL sites.
Please advise me if this method is not suitable.
Thank you. Drupal Rocks..

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE) {
  $path = _imagecache_strip_file_directory($filepath);
  if (module_exists('transliteration')) {
    $path = transliteration_get($path);
  }

  $args = array('absolute' => TRUE, 'query' => empty($bypass_browser_cache) ? NULL : time());
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
      //return url($GLOBALS['base_url'] . '/' . file_directory_path() .'/imagecache/'. $presetname .'/'. $path, $args);
	return url($GLOBALS['base_url'] . url(file_directory_path()) .'/imagecache/'. $presetname .'/'. $path, $args);
	
    case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/imagecache/'. $presetname .'/'. $path, $args);
  }
}
karishkn’s picture

Title: Without clean URLs ImageCache doesn't create folders or images » what i did to fix this problem!!!

go to settings -> File system
then change Download method to Private
That is it!

Sinan Erdem’s picture

Title: what i did to fix this problem!!! » Without clean URLs ImageCache doesn't create folders or images

Please do not change definitive titles..

elan4life’s picture

#37 worked for me.
No code hacks just http://mydomain/?q=admin/settings/file-system

Download => Private

Thanks.

sandrewj’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

The patch in $20 causes problems. Please refer to #1250156: Enable Imagecache without Clean Urls and/or with alternate image server setup instead.

rcaracaus’s picture

+1 for #83 creating a /tmp folder inside /files directory solved it for me!

fetemete’s picture

I had the same problem, and after long time in searching an issue, I fixed it by folowing the requirement of imagecache module:
+Install and enable ImageAPI module *and* one of its toolkits (GD or ImageMagick)
+Clean URL support or Private Files (more info)

I used first the ImageMagick toolkit, but images was still not being resised.

I've changed it and used GD and it works !!! That was the solution: using GD !!

Hope it will help others!

chanse’s picture

I had a lot of pain with this issue and finally fixed it. I found .htaccess file in /sites/[site name]/files/ and changed the Options +FollowSymLinks line to Options +SymLinksIfOwnerMatch. This stuff works perfect with my Drupal 7 site. Just try).
My .htaccess file in the main directory has some changes (hosting-provider recomendations):

# Follow symbolic links in this directory.
Options +SymLinksIfOwnerMatch

# PHP 5, Apache 1 and 2.

# php_flag magic_quotes_gpc off
# php_flag magic_quotes_sybase off
# php_flag register_globals off
# php_flag session.auto_start off
# php_value mbstring.http_input pass
# php_value mbstring.http_output pass
# php_flag mbstring.encoding_translation off

Ravi Shankar Karnati’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Hai nakes. u help me a lot.. thanks a lot

Jboo’s picture

Aha! This works for me also. I wish I was good at figuring this stuff out myself!

mrcaos’s picture

Version: 6.x-2.0-beta10 » 6.x-2.0-rc1

I am using rc1 version and having same problem, but I could not find the lines mentioned in #20,#26,#32. Is there anybody who has idea what can be done for rc1 version.

Regards,