This version is old school.
Please find jQuery plugins on npm.
Gridify - A Beautiful Evenly Spaced Image Grid Creator
by Pierre Tasci
This simple widget solves the need to create simple columned layouts of images with variable dimensions. Simple call it on a container element and pass in an array of image sources and watch Gridify do the rest! It will create as many evenly space columns as you desire and fill them evenly with images. It even intellegently moves around the images to try to keep the bottom of each column as close as possible but still maintains most of the order of the original list. Its ideal for portfolio websites!\ \ Also, you can add your own template to the grid as well so each image in the grid can have your own custom stylings and logic. Fully customizable and looks great too!