This post provides a solution which is specifically coded to work on the Twenty Twelve default theme for WordPress.
The code has been tested on this theme and will need slight modification to work on other default themes.
It creates a template tag which you can use to replace the default template tag in the content.php file.
- The Gist labelled functions.php contains the code you simply copy from the view raw link and paste at the end of your child themes functions.php file.
- The Gist labelled content.php contains the template tag which has been added to the code on line 21 of the content.php file, a copy of which has been copied over to the Twenty Twelve child theme.
The solution assumes you have uploaded images for each category to your child themes images folder.
The code displays the same image for all posts in each specific category meaning you will need to upload an image for each category to your child themes images folder otherwise you can add a default.