1

I have my image field's array $node->field_blog_image, but how do I render it as it does in the $page['content']?

The URI confuses me as its simply public://my_image.jpg

1 Answer 1

2

file_create_url to get the path of your image:

// $nid is the id of your node
$entity = entity_load('node', array($nid));
$uriImagefromNode = $entity[$nid]->field_image_test_field['und'][0]['uri'];
$urlImagefromNode = file_create_url($uriImagefromNode);
// $urlImagefromNode variable now has the path to the image

I hope this information be useful.

1
  • 1
    Great, however the image style has been lost! After a little digging I found that image_style_url('my_image_style', $node->field_my_image['und'][0]['uri']) did the trick. Sep 20, 2011 at 22:35

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.