Programatically linking an image to content (Drupal 7) When I create a block through views I can easily link it to the content page by setting link image to in the field's settings.  But I also have some blocks that are created programmatically and I would like to similarly add links to these images.  How would I do this?  

EDIT: Here is the code I use to create the block:

  $block = array();
  $rows = array();
  $format = 'l, F j, Y  - G:i';

  $header = array('Project Name', 'Screenshot' , 'Submitted');
  foreach ($results['node'] as $nid_array) {
    $row = $nid_array-&gt;nid;
    $node = node_load($row);
    $path = $node-&gt;field_icon_thumbnail['und'][0]['uri'];
      $variables = array(
    'path' =&gt;  image_style_url('icon_thumbnail',$path),
    'alt' =&gt; 'Thumbnail',
    'title' =&gt; 'Thumbnail',
    'attributes' =&gt; array('class' =&gt; 'some-img', 'id' =&gt; 'my-img'),
    );
      $image = theme('image', $variables);

      $rows[] = array(
    l($node-&gt;title, "node/$node-&gt;nid"),
    $image,
    date($format, $node-&gt;changed)
      );
  }
  $rows = array_reverse($rows);
  $table = array('rows' =&gt; $rows, 'header' =&gt; $header, 'empty' =&gt; 'No terms found');
  $block['content'] = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
  '#empty' =&gt; t('No terms found')
  );
  return $block;
You can use the l() function to wrap the image in a link. As it's HTML you'll need to pass the html option to the function so that it isn't run through check_plain():

$image = theme('image', $variables);

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

$rows[] = array(
  l($node-&gt;title, "node/$node-&gt;nid"),
  $linked_image,
  date($format, $node-&gt;changed)
);