| 1 |
ImageCache is a dynamic image manipulation and cache tool. It allows you to
|
| 2 |
create a namespace that corresponds to a set of image manipulation actions. It
|
| 3 |
generates a derivative image the first time it is requested from a namespace
|
| 4 |
until the namespace or the entire imagecache is flushed.
|
| 5 |
|
| 6 |
Getting Started:
|
| 7 |
|
| 8 |
1. Upload and enable both the ImageCache and ImageCache UI modules.
|
| 9 |
|
| 10 |
2. Go to Administer -> Site Building -> ImageCache. Click on the local task tab
|
| 11 |
labeled "Add New Preset" to build a new set of image manipulation actions.
|
| 12 |
|
| 13 |
3. Enter a descriptive name of your choice (e.g. 'product_thumbnail') into the
|
| 14 |
"Preset Namespace" box and click "Create New Preset".
|
| 15 |
|
| 16 |
4. Add actions to your preset that tell ImageCache how to manipulate the
|
| 17 |
original image when it is rendered for display. Available actions include
|
| 18 |
crop, scale, desaturate (grey scale), resize, and rotate. Multiple actions
|
| 19 |
may be added to a preset.
|
| 20 |
|
| 21 |
5. Each action is configured in its own form, and the actions may be reordered
|
| 22 |
from the preset's configuration form. If you need to make any changes to the
|
| 23 |
order of actions in a preset, remember to click "Update Preset" when you're
|
| 24 |
finished.
|
| 25 |
|
| 26 |
Viewing Manipulated Images:
|
| 27 |
|
| 28 |
Your modified image can be viewed by visiting a URL in this format:
|
| 29 |
|
| 30 |
http://example.com/files/imagecache/preset-name/files/image-name.jpg
|
| 31 |
|
| 32 |
For example, if your preset is named 'product_thumbnail' and your image is
|
| 33 |
named 'green-widget.jpg', you could view your modified image at:
|
| 34 |
|
| 35 |
http://example.com/files/imagecache/product_thumbnail/files/green-widget...
|
| 36 |
|
| 37 |
NOTE: Each role that wishes to view the images generated by a
|
| 38 |
particular preset must be given permission on the admin/user/permissions
|
| 39 |
page.
|
| 40 |
|
| 41 |
ImageCache also defines a theme function that you can use in your modules and
|
| 42 |
themes to automatically display a manipulated image. For example, to use the
|
| 43 |
theme function in a .tpl.php file, add the following line where you would like
|
| 44 |
the image to appear:
|
| 45 |
|
| 46 |
<?php
|
| 47 |
print theme('imagecache', 'preset_namespace', $image_filepath, $alt, $title, $attributes);
|
| 48 |
?>
|
| 49 |
|
| 50 |
Change 'preset_namespace' to the name of your imagecache preset and make sure
|
| 51 |
that $image_filepath or some other variable contains the actual filepath to
|
| 52 |
the image you would like to display.
|
| 53 |
|
| 54 |
$alt, $title and $attributes are optional parameters that specify ALT/TITLE
|
| 55 |
text for the image element in the HTML or other attributes as specified in the
|
| 56 |
$attributes array.
|
| 57 |
|
| 58 |
Using ImageCache with Contributed Modules:
|
| 59 |
|
| 60 |
ImageCache presets can be put to use in various other modules. For example, when
|
| 61 |
using CCK with the Imagefield module, you can use the "Display fields" local
|
| 62 |
task tab to choose a preset to apply to images in that field. Similarly, you
|
| 63 |
can specify a preset when displaying images attached to nodes using Imagefield
|
| 64 |
in a View through the Views UI.
|
| 65 |
|
| 66 |
For more information, refer to http://drupal.org/node/163561.
|
| 67 |
|
| 68 |
(Images, page names, and form field names may refer to previous versions of
|
| 69 |
ImageCache, but the concepts are the same.)
|