From http://wpsnipp.com/index.php/functions-php/enable-post-thumbnails/