From http://wp-snippets.com/automatically-set-the-featured-image/