How do I link a thumbnail image to its content programatically?
Something like this...

$imgpath = file_load(($node-&gt;field_image[LANGUAGE_NONE][0]['fid']))-&gt;uri;
$image = theme('image_style', array('path' =&gt; $imgpath, 'style_name' =&gt; 'thumbnail'));

$link = l($image, "node/$node-&gt;nid", array('html' =&gt; TRUE));
print $link;