In drupal 7 theme, I have the following file:

field--field_photo.tpl.php clearfix"> >:  > $item) : ?> ">

Inside render($item) lies an image with img tag How I may deconstruct this item, so that I write my code with img tag? The reason is just that I want to add a class to this img tag. thanks

The path to the images are save in public:files format

1 Answer 1


I usually use Devel module to figure out things like this. Install and enable Devel, then add something like this to your field template file:

<?php kpr($item); ?>

This will show you all the contents of $item (arrays and objects). Then you can just print the part that you want (the img tag in this case), wrapped in the extra class.

  • thanks. is this output invisible to anonymous users? I was already use devel. How come kpr shows some extra output like "children" which shows the full html output (img tag with full link) whereas the normal krumo display does not?
    – john
    May 29, 2011 at 11:45
  • a part of the question remains. how to convert the public:uri that is saved in the database to a full url.
    – john
    May 29, 2011 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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