First of all we already have topic thumbnails you can enable it from the ACP.

If that isn't enough you can take a look at the code that makes it work and duplicate that.