Plain Unstrucutred HTML Content Types, How to Pull image from them in Views This is a plain unstructured node with no CCK structure or anything like that (the site includes thousands of posts so it is impossible to retroactively go back and re-insert the images in using CCK).

How can I pull the first image in the node out and use that image within a view as a thumbnail image? (It's a related posts view)

I'm not 100% sure how to create a view theme, the drupal documentation on it is really confusing and I can't find a good tutorial on how to create a custom view theme either.  So since I think that is the best solution if you know how to do that, could you point me to a tutorial or something that actually teaches you how to create your own themed view (one that makes sense).

Thanks for any tips or advice.
you will need to only create one view theme. That will be a theme for the BODY field of your node. It's actually super simple.


create a PHP file in your theme folder called views-view-field--YOURVIEWNAME--body.tpl.php 
your file has one variable you need to worry about, $output and that's the HTML. Write your PHP code to isolate the very first image tag and then this site has a nice example of how to do that


I think the code in this file would end up looking like this

  $first_img = '';
  $numMatches = preg_match_all('/&lt;img.+src=[\'"]([^\'"]+)[\'"].*&gt;/i', $output, $matches);
  if($numMatches){
    $first_img = $matches [1] [0];
  }else{ //Defines a default image
    $first_img = "/images/default.jpg";
  }
  echo '&lt;img src="' . $first_img . '" alt="thumbnail" class="thumb"/&gt;';



add some CSS to make the thumbnail, or alternatively you can use theme with imagecache I think.
refresh your template cache


You're done!