title: Set featured image via post content programmatically
body: <p>I was trying to add featured image from post content. My idea is to set the first image of the content as featured image of the post.</p>
  
  <p>I wrote this in my <em>funtions.php</em> </p>
  
  <pre><code>    add_action('publish_post', 'auto_featured_image_publish_post');
           function auto_featured_image_publish_post($post, $post_id) {
             $thumnail_id = //something I need help with
             set_post_thumbnail( $post, $thumbnail_id );
           }
  </code></pre>
  
  <p>This is just an idea how I want to do this. </p>
  
  <p>Please help. Thanks</p>