Howdy,
could anyone explain how use imagecache to auto-generate thumbnails for submitted CCK content-types containing an imagefield?
I tryed with all the latest versions of involved modules installed, i have .httaccess and cleanurls enabled.
1. i setted up my "thumbnails" ruleset with resize 120x120 and crop 100x100.
2. updated every action and the whole ruleset.
3. flushed the ruleset.
4. submitted a CCK content type containing an imagefield.
5. re-flushed the ruleset.
At this point where am i supposed to get the thumbnail and how can i show it in my teaser (but not in full-node view)?
Note: on first flush i got following Warnings:
* Flush Ruleset: 1
* rulesetdir: sites/mysite.com/files/imagecache/thumbnails/sites/mysite.com/files
* warning: opendir(sites/mysite.com/files/imagecache/thumbnails/sites/mysite.com/files): failed to open dir: No such file or directory in /home/mysite/public_html/drupal/modules/imagecache/imagecache.module on line 357.
* warning: readdir(): supplied argument is not a valid Directory resource in /home/mysite/public_html/drupal/modules/imagecache/imagecache.module on line 358.
so i manually created the (not ideal) requested folder structure:
/files/imagecache/thumbnails/sites/mysite.com/files
Might this be a bug related to the "create recursive mkdir for imagecache" bug, not completely fixed (i am running multisites)?
Thank you lot in advance for any help you might give (generating thumbs in teasers for CCK is driving me insane..uhff ;-\ ),
Marco
Comments
Comment #1
dopry commentedin your template put something along the lines of...
if you don't include the dynamically generated image url in your theme it won't show up.
Comment #2
marcoBauli commentedDopry, thanks for the quick hand,
so you say the module is supposed to generate the thumbnail image automatically on node submission, and store it in
/files/imagecache/[rulesetname], so i just have to recall it with a simple<img src?Actually no thumb is dinamically created on node submission. Also tryed pasting
into my ContentTemplate, but still no image generated nor thumbnail displayed..might that Warning i posted above the reason? or is there something else i am doing wrong?
Comment #3
dopry commentedIt doesn't generate a thumbnail when the node is submitted. It generates the thumbnail when it is requested...
That variable may be wrong.. You will have to inspect your node and figure out the var name for the filepath you need a thumbnail for, use print_r or something similar.
Comment #4
marcoBauli commentedaha, thanks Dopry, i got bit better how it works now.
But i tryed inserting different possibilities of code in my Contemplate teaser:
May Contemplate be the cause? or that no directory path was generated on first submission of the ruleset (see the note on the initial post)?
Comment #5
dopry commenteddoes just printing out the variable without making an image show you anything?
Comment #6
marcoBauli commentedno, nothing printed out, as the code just wasn't there..
i will try tomorrow some more with another multisite and with a single one (fresh install) and come back here
Comment #7
dopry commentedI've found some issue with multisite installs and imagefield...
If you are storing files in sites/X/files you probable need to alias sites/X/files/imagecache files/imagecache
otherwise funkiness ensues... I don't really use multisites myself, but when I get time to return to imagefield I'll try a better work around....
basically the rule is that the url to the imagecache call back has to be the same as the generated image...
you might need to comment out the rewriterules off in the .htaccess that drupal now installs in the files folder.
and and modify the Options stanza to be Options FollowSymlinks.
Comment #8
marcoBauli commentedstill no luck..
with:
<?php print '<img src="/sites/mysite.com/files/imagecache/thumbnails/'.$field_main_image[0]['view'] . '">'; ?>a big (no thumbnail) broken image appears for a second, then vanishes,
while with:
<?php print '<img src="/sites/mysite.com/files/imagecache/thumbnails/'. $node->$field_main_image[0]['view'] . '">'; ?>nothing happens at all.
Also tryed with the complete URL that throws no errors on rule generation
/sites/mysite.com/files/imagecache/thumbnails/sites/mysite.com/files/but same results as above. :(
could this be Contemplate fault? or CCK Imagefield fault? please help!
Comment #9
introfini commentedthe code is like this:
Hope it helps :-)
introfini
Comment #10
marcoBauli commentedthanks introfini, i've tried almost all the possible combinations of $node, $field_main_image, [0] and paths but seems this is an issue related to multisite installs.
Will soon try with a fresh single test site and report here! cheers
Comment #11
introfini commentedYou are right; it's an issue with multi-site installs.
If you give the full address it works, I’ve tested it.
Comment #12
marcoBauli commentedintrofini: sorry for the n00bnes, but could you please post the code (full path) that worked for you on multisite? :o
i tryed many combinations (well, not all, but geez!) and didn't succeed..
also did you get that warning i described in the original post above at top of this thread?
Comment #13
dopry commenteddoes aliasisng the files path /imagecache to files/imagecache resolve the issue for the multisite?
Comment #14
introfini commentedthis is working:
Comment #15
marcoBauli commentedok, found some time to set up a fresh Drupal install (single site) and test little more.
Except for the initial warning:
that forced me to create manually the needed directory structure /imagecache/resize/files into my /files folder, i managed to output my thumbnails using introfini's code at #9 (obrigado ;) only on a single Drupal site.
It DOES work on a single-site Drupal install in the form mydomain.com/files.
It DOES work on a "fake" multisite install in the form mydomain.com/drupal1/files, mydomain.com/drupal2/files
It DOES NOT work on a true multisite install in the form mydomain.com/sites/mysite1.com/files, mydomain.com/sites/mysite2.com/files.
Tryed also with always introfini's code at #24 above, but nothing, no thumbnails show up.
As a non-developer in need of this functionality something like 3 weeks ago, i'd apreciate hugely any help from anyone who knows where to put his hands on this to make it working!
Comment #16
nicholasthompsonThats because your files folder probably wasn't writeably by the apache user (or whatever user your webserver app is running under).
Comment #17
marcoBauli commented@njt: about folders creation, that is strange, because the standard /files and /tmp directories did create, so why only imagecache ones shouldn't? (but well, does not take too much time to create them manually anyway!)
about outputting images: i tryed also changing the permissions of my /files, /images and /imagecache folders, but still i wasn't able to show resized images....
you think this problem could be caused by wrong permissions? if yes, what are the right permissions to set?
..still i don't think this could be the cause, because i tryed already with 777 and didn't work neither...
thx
Comment #18
marcoBauli commentedEverything seems to work just fine with latest v. 1.9 released today!
(Note for others striving with this: I had to remove completely any trace of the older imagecache from my database to make it work though!)
Finally i can unleash the power of this module and generate tons of thumbs now ;-) Thank you Dopry and all!
Comment #19
marcoBauli commentedComment #20
(not verified) commented