Implement thumbnails, cleaner gallery code.
Thumbnail generator function.