When I write a story I add some images with image cache, but when I want to see the preview the image cache images are not generated[using image cache + image field + filefield +cck - all directories under /files and /files are chmod 777, ]; images are generated just if I save the story.
Any ideas why ?

Comments

drewish’s picture

Status: Active » Postponed (maintainer needs more info)

i'm guessing that you're using private file transfers. am i right?

idflorin’s picture

No, I'm using "Public - files are available using HTTP directly."

drewish’s picture

is your temporary directory located under the webroot and accessible by the browsers?

idflorin’s picture

sean.mtm’s picture

Version: 6.x-2.0-beta2 » 6.x-2.0-beta9
Status: Postponed (maintainer needs more info) » Needs review

I ran into the problem here, too. The problem only occurs when trying to preview a node with CCK image fields that have not yet been written to the DB (and thus, does not have a NID). In the case of my CCK-based image fields, $element['#node'] contains the unsaved node, which does the job if I've uploaded images.

There's another problem that pops up if there's an empty field (ie - optional image field w/ no image) where theme_imagecache_formatter() calls imagecache_field_formatter() passing $element['#field_name'] in where a field structure is expected (for looking up things like $field['use_default_image']). My patch just avoids the problem by not passing empty images across but there's probably a better way to do it.

Here's a patch - it's kind of ugly but it works.

Index: imagecache.module
===================================================================
--- imagecache.module   (revision 2966)
+++ imagecache.module   (working copy)
@@ -629,7 +629,10 @@
 }

 function theme_imagecache_formatter($element) {
-  if (isset($element['#item']['nid']) && $node = node_load($element['#item']['nid'])) {
+  if ((isset($element['#item']['nid']) && $node = node_load($element['#item']['nid']))
+      || (isset($element['#node']) && $node = $element['#node'] && !empty($element['#item']['fid']))
+     ) {
+
     return imagecache_field_formatter($element['#field_name'], $element['#item'], $element['#formatter'], $node);
   }
 }

drewish’s picture

Status: Needs review » Postponed (maintainer needs more info)

i just committed some other formatter changes so this might not be relevant any more. could someone go grab -dev and test it out?

fizk’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)