D7 Field template syntax 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:

&lt;div style="border:10px solid cyan;margin-bottom:20px"&gt;

&lt;?php
$link = 'http://www.desertcow.co.uk/pirates.mp4'; // url link?&gt;
&lt;a href="&lt;?php print $link;?&gt;"&gt;&lt;img src="/download.jpg"&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;div style="border:10px solid pink;margin-bottom:20px"&gt;
&lt;a href="&lt;?php print render($items); ?&gt;"&gt;&lt;img src="/download.jpg"&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;div style="border:10px solid red;margin-bottom:20px"&gt;
&lt;a href="&lt;?php print render($items); ?&gt;&lt;img src="/download.jpg"&gt;&lt;/a&gt;
&lt;/div&gt;


The result is here and you can see that the syntax for the pink and red boxes is not correct.

Can anyone please tell me the correct syntax or is there some reason that this approach is not going to work?

Thanks...
This is because you're rendering the full item when all you want is the url as a string, if you add this line of code in the template you will be able to see where the url is held in the $items array.

&lt;?php var_dump($items); ?&gt;


then you can find the part of the array where the url string is so your final markup would be something like this.

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