1

I am having trouble getting imagecache to generate a thumbnail based on a preset I have created named 'thumbnail'. I have an cck image_field and a custom node view. The code I am using to output my images is:

<?php foreach($node->field_comm_gallery as $galleryItem) { ?>
    <?php print theme('imagecache', 'thumbnail', $galleryItem['filepath'], $alt = '', ''); ?>
<?php } ?>

The output I get from the following is:

<img class="imagecache imagecache-thumbnail" title="" alt="" src="http://127.0.0.1/sites/default/files/imagecache/thumbnail/cedimages/3388564188_4427beac12_b_0.jpg"/>

<img class="imagecache imagecache-thumbnail" title="" alt="" src="http://127.0.0.1/sites/default/files/imagecache/thumbnail/cedimages/3388564188_4427beac12_b_2.jpg"/>

Everything looks correct but those files do not exist in that folder.

My question: Is the print theme(..) call supposed to generate the thumbnail on the fly when it is called, or is the thumbnail generated when a node is created/updated?

I am using the GD Image processer and receive no errors.

ibuck
  • 495
  • 1
  • 5
  • 16
  • Any reason you haven't set the preset in the display field setiing for the node, or in the views? – googletorp Jan 06 '10 at 21:44
  • I have set the display field setting to be "thumbnail image" for the full node view. I am not using views, but just a custom page tpl for my content type. Do I have to call the image different in php if I want to use the display field setttings? – ibuck Jan 06 '10 at 22:13
  • Yes, ImageCache is supposed to work on the fly. Have you checked your file system settings on /admin/settings/file-system? Imagecache needs an accessible temp folder. Also, did you check your apache/php error log for errors? – marcvangend Jan 06 '10 at 22:39

2 Answers2

0

The node field value has within it the display value already generated. So using theme function is not needed. But the file should be created regardless. It looks like the problem is the permission to either Drupals temp folder or the files folder. Take a look at those in the files settings.

googletorp
  • 33,075
  • 15
  • 67
  • 82
0

Thanks for the help. It actually turned out to be this bug (http://drupal.org/node/540486#comment-2356560)

I had to remove the & from the function parameters in imageapi.module

function imageapi_gd_image_resize(&$image, $width, $height)

No clue why, but it seems to break when using php 5.x

ibuck
  • 495
  • 1
  • 5
  • 16
  • I have found core to be pretty good (though I have seen a couple fixed issues), but many contrib modules are still iffy with PHP 5.3.x. Keep in mind that Drupal 6 core is still PHP4 compatible, and many contrib modules try to be as well. The problem occurs because PHP 4 requires functions to declare that parameters are passed by reference, and PHP5 it was changed that objects are passed by reference by default. 5.3 is stricter in its reference handling, and some code will run fine on PHP5.2 but cannot also be compatible with both PHP4 and PHP5.3 – gapple Jan 07 '10 at 22:05
  • I would suggest sticking with PHP5.2.x if you can for running Drupal 6, because of the few significant differences in PHP5.3.x. Drupal 7 will be dropping support for PHP4, so there shouldn't be any compatibility issues between different PHP 5.x versions. – gapple Jan 07 '10 at 22:20