General idea is:
- Create a database with a specified name. Use indexedDB.open() for that.
- Create an objectStore.
- Read a file(image in your case) as blob. Use XMLHttpRequest for that.
- Create a db transaction.
- Save file blob in th DB.
- Read file blob from database.
- Create URL using URL.createObjectURL() function
- Insert url in src attribute in an image tag.
See more: https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/