Text Size
Sunday, May 20, 2012
Get a look down
General >> Displaying items by tag: module
Displaying items by tag: module

You can use imagecache directly in your module, invoke a preset, and apply it on an uploaded image with this code snippet :

1
2
3
4
5
6
7
8
9
10
// $preset: the name of your preset
// $image['filepath']: the path to your file. E.g: sites/default/files/my_picture.jpg
// $alt: the alt of your <img> tag
// $title: the title of your <img> tag
// $attributes: your can add attributes to the <img> tag. E.g: $attributes = array('class' => 'mypic')
//          will add a class 'mypic' to your image.
print theme('imagecache', $preset, $image['filepath'], $alt, $title,  $attributes); 
 
// E.g:
print theme('imagecache', 'my_custom_thumb_preset', 'sites/deafult/files/my_picture.jpg', t('My picture alt'), t('My picture title')); 
Published in Code snippets
Usefull tricks