My D7 content type has a field for an MP3 file. I want the field to display as an image which the user can then right click to download the file ie like this. My field template file looks like this:

var_dump($items) =

<div style="border:10px solid violet;padding:4px; margin-bottom:10px">
<?php var_dump($items); ?>

print_r($form) = 

<div style="border:10px solid maroon;padding:4px; margin-bottom:10px">
<?php print_r($items); ?>

<div style="border:10px solid orange; margin-bottom:20px">    

<?php echo $items[filesize]; ?>
<?php echo $items['filesize']; ?>
<?php echo $items["filename"]; ?>
<?php echo $items['url']; ?>
<?php echo $items['uri']; ?>

<div style="border:10px solid green;margin-bottom:20px">
<a href="<?php echo $items['url']; ?>"><img src="/download.jpg"></a>

The result is here. Can anyone please tell me why the orange box is empty / not printing out, and the correct syntax re the green box to make the image link to the MP3 file URL instead of the page URL?


1 Answer 1


I think your are printing wrong the array $items. It should be something like

print $items['#file']->filename;

The same is happening with the image issue.


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.