For one linked image per post, override that link with a permalink when on the main page

My solution was to work in the twentyten theme folder, the file “loop.php”

Around line 145 I did this:

<?php $content = get_the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) );
  // http://stackoverflow.com/a/6366390/1195835
  // http://stackoverflow.com/a/11886237/1195835
  // http://stackoverflow.com/a/15469353/1195835
  $doc = new DOMDocument();
  $doc->loadHTML($content);
  $finder = new DomXPath($doc);
  $classname = "post-main-image";
  $nodes = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]");      
  foreach($nodes as $node){
   $node->setAttribute('href',get_the_permalink());
  }
  echo $doc->saveHTML();
?>

Then in the edit post screen, I simply type “post-main-image” in the “Link CSS Class” form field and update. I would expect something similar to work in other themes as well.