This is also a memory leak. Since the items[] array of the preview gallery stores all of these image objects, this memory-backed thumbnail blob will be in memory for possibly hundreds of images.

We either need to impose a maximum number of elements in the items[] array, or not store the thumbnail along with each item.  In the latter case, you'd only store the current thumbnail, and might have to re-created thumbnails when photos are deleted.  (Which seems fine to me.)