Theme image cache function in drupal
On:
Saturday, May 16, 2009 - 22:59
Used to resize images, scale and crop images. Use it allot.
Install the image cache module. Create a preset and call it with this function.
<?php
example $image = theme('imagecache', 'nieuws_teaser', $node->field_image[0]['filepath'], $node->field_image[0]['data']['alt'], $node->field_image[0]['data']['title'], array('description' => $node->field_image[0]['data']['description']));
?>
<?php
@namespace : name of preset
@path : path of image
@alt, title, attributes : html attributes of the img tag
?>
<?php
function theme_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
$attributes = drupal_attributes($attributes);
$imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
return '<img src="'. $imagecache_path .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}
?>
Add new comment