Theme an image field in Drupal 7
If you have a node with an image field in Drupal 7 and need to manually print the image, here is a quick code snippet for theming the image:
$my_image = array( 'style_name' => 'my_style', //the image style created 'path' => $node->field_my_image['und'][0]['uri'], ); print theme('image_style', $my_image);
As you will notice, the image field is called "my_image" and is accessible from $node->field_my_image['und'][0]
You will need to make sure you set up "my_style" inside the Image Styles section in the D7 Admin interface.



Discussions
Hi,. Thanks for info but how
Hi,. Thanks for info but how can load all images in this field.. if we have like 5 images..
Thanks
This might help
I am not sure exactly what you are trying to do, but if you just need to print multiple images from the same field you can probably use a foreach loop.
Something like this might work:
Post new comment