Getting ImageAPI and ImageCache cope with Drupal 6
Setting up a gallery in Drupal may easily turn into a lot of hassle. While Drupal is one of the most flexible Content Management Systems out there, it’s also one of the most complex on top of million modules for pretty much everything including the functionality for the simple gallery.
Themed gallery in Drupal
There are several combinations of modules to get a themed gallery going in Drupal 6. One such way is by using following:
- CCK with FileField for creating a custom content types such as Image
- ImageAPI with GD2 or ImageMagick for raw work on images
- ImageCache for processing preferences
- Thickbox/Lightbox for nice inline JavaScript preview
Problems with ImageAPI and ImageCache
The above set provides a rather flexible platform but since all modules are at different development stages, they might not work together. In the circumstances, with ImageAPI 6.x-1.6
and ImageCache 6.x-2.0-beta9
it’s likely to throw an error:
imagecopyresampled(): supplied argument is not
a valid Image resource in
/home/.../sites/all/modules/imageapi/imageapi_gd.module
on line 126.
Same happens to the alternative ImageMagick processing.
Workaround for ImaegAPI and ImageCache
Fortunately the workaround is rather trivial:
- Open Drupal settings at
/sites/default/settings.php
- Find PHP settings block in the code around
ln 148
and paste the lineini_set('zend.ze1_compatibility_mode', 0);
to disable PHP 4 compatibility mode.
Since FileField module sets the requirement for PHP 5 already, you don’t really have to worry about the compatibility mode with Zend Engine 1 (PHP 4).
Related resources: