Posted by glide on September 21, 2011 at 4:06pm
So im trying to theme a node with an image. Seems like a pretty simple basic thing, so Im probably missing something simple here.
Its a custom type for authors withe names, email, address, etc, and a PICTURE.
I can theme all the text fields, they are easy to get like this:
print $node->field_staff_first_name[$node->language][0]['safe_value'];
but how do I get images? the path doesnt seem to be in $node like it was in D6
In D6 I could do:
<?php
print $node->field_staff_pic[$node->language][0]['safe_value'];
?>
in D7 I can't find a variable with the image path, I think it has something to do with the new rendering engine. any ideas or pointers?
Comments
Here is an example from one
Here is an example from one of our node--content_type.tpl.php
<?php $product_images = render($content['product:field_image']); ?><div class="product-images-container clearfix">
<?php if ($product_images): ?>
<?php print $product_images; ?>
<?php endif; ?>
</div>
This prints multiple images, but you can see how we actual render the image.
<?php print render($content['product:field_image']); ?>Also (quick edit), I don't think its recommend printing fields in the way you did it due to language.
Hopefully this helps.
Below are links to discussions on this, you can also do a search for "drupal entity load field"
http://dominiquedecooman.com/blog/drupal-7-tip-get-field-values-entity-o...
http://drupal7ish.blogspot.com/2011/03/getting-field-data-out-of-entitie...