I’m using drupal 7.x and am creating a node content-type template. My content type has multiple custom fields including an image field. I am attempting to add the imagefield and its attributes to the node template. I can display the image using
print render($content['field_custom_image'][0])
however i also want to display the filename and the title text. I tried code below but it doesn’t display anything.
print render($content['field_custom_image'][0]['und']['title'])
In Drupal 6 I was able get this to work using:
print $node->field_custom_image[0]['data']['description']
My output when I execute print_r($node) is the following.
[field_reclaimer_image] => Array ( [und] => Array ( [0] => Array ( [fid] => 8 [alt] => [title] => test title [width] => 1117 [height] => 651 [uid] => 1 [filename] => 24-1033_angle_02_1339771175.jpg [uri] => public://images/24-1033_angle_02_1339771175.jpg [filemime] =>…
You can do this like so:
echo $node->field_custom_image['und'][0]['filename'];echo $node->field_custom_image['und'][0]['title'];und and 0 are the wrong way round. If you wrap your
print_r()in<pre>tags you’ll see a much more nicely formatted array which is a lot easier to read.