Adding code to show image thumbnails. Please do not look at the code.