This version is old school.
Please find jQuery plugins on npm.
Justified Gallery
by Miro Mannino
This is a JQuery plugin that allows you to create an high quality justified gallery of images. Fill all the spaces!