I have imagefield and imagecache installed, and want to be able to upload images and have the thumbnail created automatically.

I have created the preset in the imagecache settings, but for some reason, the files upload to /sites/default/files, not /sites/default/files/imagecache/PRESETNAME/ as they should, and hence the images are broken when displayed.

Any ideas?

Comments

vasheck’s picture

subscribing...

WorldFallz’s picture

File upload and imagecache preset generation are unrelated functions. Imagefield images are uploaded to whatever directory you've specified in the imagefield configuration settings. This is the original file and is untouched by imagecache. Imagecache presets are then stored in the imagecache/* directory structure once the presets have been generated. The original file in the imagefield directory remains unchanged.

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

vasheck’s picture

Hi WorldFallz,

First of all thank you for your reply! What you said makes sense... and that's how things should work...
I'll try to explain my issue...

My settings:

Administer » Site configuration » File system

File system path:
sites/default/files

Temporary directory:
sites/default/files/temp

Download method:
Public - files are ...

So you can see that the "original images" should (and do) get uploaded to the "files" directory...

Here's a brief description of what I do and what happens:

I have "mycontenttype" set up with an imagefield ("gallery") in place

1) I create a new post:
create content > mycontenttype > browse > upload (I see the thumbnail once uploaded) > submit

2) After submission:
I see the title of the imagefield ("gallery") but nothing is displayed underneath...

So I check the source code and this is where the problem is... I'll try to explain as briefly as possible what happens when I change the imagefield display settings (under display fields > "gallery" (imagefield):

a)
Display fields: image
Link in source: http://mysite.com/test/sites/default/files/test3.png
Result: displays the full (original picture)

b)
Display fields: large (that's my resized image preset)
Link in source: http://mysite.com/test/sites/default/files/imagecache/large/test3.png
Result: no image displayed

c)
Display fields: thumb
Link in source: http://mysite.com/test/sites/default/files/imagecache/thumb/test3.png
Result: no image displayed

And the last piece of info about what's happening with the files on the server...and that's when it gets really bizzare...

The original image is uploaded to /files/ directory (as you pointed out that "upload module" does)...
However, the thumbnail (test3.png.thumb.jpg) is created but in the /files/ directory as well...

and there are no directories under /files/imagecache/...

If everything worked well it should look something like this:

/files/imagecache/thumb/test3.png.thumb.jpg
/files/imagecache/large/test3.png (or test3.jpg)

but that's not the case... instead I have this:

/files/test3.png
/files/test3.png.thumb.jpg

So there's clearly something not set up properly... and I'm out of ideas where/how to fix it.

To summarize I see two major problems with this:

a) img source points to the correct spot but looks for an incorrect file (test3.png vs. test3.png.thumb.jpg)
b) the preset images get saved / created in the wrong directory (files/ vs. files/imagecache/thumb/...)

Any help is appreciated!

Thanks!

WorldFallz’s picture

I can't be sure, but my first guess is that the problem has to do with the fact your drupal install is in a subdirectory (/test). I've had nothing but problems with that setup. I've since moved all my dev sites to subdomains (ie test.example.com instead of example.com/test) and I've never had any problems since.

I don't know if that's an option for you but you may wish to consider it. Otherwise maybe check out the imagecache issues queue and see if anyone else has had problems with subdirectories.

sorry that's not more helpful =/

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

arh1’s picture

off the top of my head, does Drupal have enough permission on your server to create the imagecache directories? i would imagine it'd throw an obvious error if not, but just checking... i can't remember when exactly in the configuration process -- i think it's right after you create the imagecache presets -- you should see a message that the appropriate directory was created for the preset.

cebonus’s picture

what vasek802 has described is exactly what my problem is.

i have drupal setup in the root directory though, so the fact that his is installed into /test/ i would say isn't a contributing factor.

i have been trying to figure this out for ages, hopefully someone can shed some light on it.

cebonus’s picture

Just figured it out. I didn't have the GD2 and ImageMagick APIs enabled. Enabled them and works perfect now :)

I also changed the imagecache preset directories to 777 permission, that may also be necessary.

drupdruppalpal’s picture

hello, i have the same problem. i have enabled the GD2 kit and i have tested with 777 and 775 permissions for the imagecache folder but, but it still generating the thumbnails out of the imagecache folder.
what can i do? vasek, have you solved your problem?
thanks in advance

htimsmnad’s picture

same problem too.. anyone?

htimsmnad’s picture

Changed the 'Download Method' to 'Private' instead of 'Public' in System Configuration>Filesystem

WorldFallz’s picture

Not the best answer-- there are side effects of setting the download method to 'private' and it's difficult to go back if you change your mind later on.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

htimsmnad’s picture

Any other suggestions?

WorldFallz’s picture

Difficult to say without more info... 90% of the time it's a permissions problem. But setting the file system to private is like amputating your finger to cure a hangnail.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

drupdruppalpal’s picture

Does the private download method more memory than the public?
im thinking on chage it but im afraid

WorldFallz’s picture

I'm not sure about the memory usage, but there are adverse side effects. ALL files will be handled privately-- including image files which can slow things down some. Also the any colorable modules won't work and I'm sure there's other problems. There are also contributed modules that are incompatible with the private download method (like imagecache)-- usually they will put a warning right on the project page.

htimsmnad’s picture

Tried a few various things now. Including:

- Permissions are all set at 775 or 777
- User permissions set in drupal
- Increased memory

I'm using CCK to input my image and then Views to display my presets. Could there be a problem there?

It seems not not even create the presets. Uploads the image ok, creates a thumb (image.jpg.thumb.jpg) in the same directory (sites/default/files) However when I run my page it does not generate the images in their preset forms or the folders. The HTML displays the links to the images (sites/default/files/imagecache/presetname/image.jpg) however.

Drupal 6.9
CCK 2.1
Views 2.2
ImageAPI 1.3

Any suggestions? Thanks!

hunterjones’s picture

Is what you've stated:

Private - files are transferred by Drupal. --allows imagecache to work but disables viewing of normal Images.

So am I to have my clients switch the variable to - Public - files are available using HTTP directly. - for viewing images, then back to Private, have some sort of "View" create all possible imagecache manipulations then switch back to public for normal Images?

That's what I'm doing on a couple of sites, but to convey this to the clients, well you know.

So basically I'm asking since Image does not support Private, is there something like Image that can provide that nice thumbnail when being added in a field of CCK?

Or am I just lost here?

WorldFallz’s picture

imagecache not working with the file system set to public is an anomaly (i have it working that way on several sites with no problem as do probably 100s of others). It works fine with public and you should pick public unless you have both 1) a specific reason not to do so and 2) a thorough understanding of the consequences.

And no, private, does not disable the viewing of normal images but it will change the URLs of those images so existing IMG tags will more than likely be incorrect.

The private file system is basically an edge case-- you're best bet is to figure what the config problems are with the module and get it functioning properly.

hunterjones’s picture

I've been looking at this for a config guide:

http://drupal.org/node/346042

Any other config hints?

I'm not using Clean URLs (because this version of ImageCache doesn't require it.) But maybe it does for a public file system?

Thanks for the help, sorry it's taken me this long to get back to the message, trying to keep the clients out of this type of stuff so it's not the biggest issue. Just have a new site that would work well with a public file system.

Enzman’s picture

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

I would love to hear if there are better solutions available as I see this setting may not work with some other modules.