4

I tried using this code, but it does not work.

<?php print $node->field_slider_image['und'][0]['filename']; ?> 
1
  • 1
    use dpm() function to display the render array, then you might see the correct one.
    – uwe
    Feb 8, 2012 at 15:27

1 Answer 1

3

The full file object isn't necessarily loaded into the node object, you could try loading it manually and grabbing the filename/URL that way:

$file = file_load($node->field_slider_image['und'][0]['fid']);

// Filename
print $file->filename;

// URI e.g. public://image.jpg
print $file->uri;

// URL e.g. /sites/default/files/image.jpg
print file_create_url($file->uri);
0

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.