Also see: https://wordpress.org/plugins/lightbox-photoswipe/
This plugin integrates the JavaScript library PhotoSwipe to display linked images in posts or pages. All pictures will be used, regardless if they are part of a gallery or single images.
You can find the source at GitHub.