How do I link a thumbnail image to its content programatically? I have the following php code in a rule. It displays a picture that was uploaded by a user.

How do I link the thumbnail to the content?

$imgpath = file_load(($node-&gt;field_image['und'][0]['fid']))-&gt;uri;
print theme_image_style(array( 'path' =&gt; $imgpath, 'style_name' =&gt; 'thumbnail'));
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;