2

The following code I used once in node.tpl.php template to construct a jquery gallery in Drupal 6 where I found somewhere.

 <ul id="jgallery">    

   <?php foreach($field_myimage as $key => $image):?>                  
    <li><?php print theme('imagecache', 'imagecache_name', $image['filepath']); ?></li>
   <?php endforeach; ?>                                                   

 </ul> 

I wonder how it should be used in Drupal 7, the image style. And how to add in extra attributes like class. Thanks

2

I think theme_image_style() is what you're looking for.

Eg:

$image = array(
    'style_name' => 'style_name', // imagecache_name
    'path' => $image_uri, //  uri (String, 27 characters ) public://image.jpg
    'alt' => 'Alt text here',
    'title' => 'Title text here',
);

print theme('image_style', $image);
2
  • Thanks! Can anyone convert for me into D7. I'm still a newbie to this programming. Thanks.
    – Adamtan
    Oct 17 '12 at 1:36
  • I updated the answer Oct 17 '12 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.