Completely rewritten to use hashes and previews for photos.