News for hackers. Stuff that matters.
Re:The algorithm for a perfectly balanced photo gallery by quarterto on Monday August 12, 2013 @06:30AM (#6198519)
I just implemented pretty much the same thing from scratch for my wedding gallery¹.

For each row, it tries 3-10 images, sums their aspect ratios, divides the total row width by the sum to get a candidate height, then picks the height that's closest to the average of the existing rows.

To make things look a bit nicer, it rejects candidate rows with the same number of images as the last row.

I might release the code on Github if I can make it modular enough. Currently it depends on jQuery but that's really only for element creation.

¹ http://mattandsophiegetmarried.com, I'm the guy with the waistcoat, purple cravat and massive grin.

Re:The algorithm for a perfectly balanced photo gallery by pubby on Monday August 12, 2013 @07:32AM (#6198659)
I'm not seeing any images on Chromium. Just a blank white screen with "Matt & Sophie's wedding photos" at the top.

Congrats on the wedding though.

Re:The algorithm for a perfectly balanced photo gallery by sdoering on Monday August 12, 2013 @07:51AM (#6198694)
Maybe Chromium is blocking the redirection to cloudfront, where the images are hosted? I had to tell Firefox's RequestPolicy, to let these requests pass...
Re:The algorithm for a perfectly balanced photo gallery by FreeFull on Monday August 12, 2013 @07:58AM (#6198710)
I end up with some of the photos ending up behind other photos. Firefox 23 here.
Re:The algorithm for a perfectly balanced photo gallery by aestra on Monday August 12, 2013 @12:15PM (#6199975)
Same in Firefox 22. Scrolling seems broken, and removing the "find on page" part of Firefox clears all the images.
Re:The algorithm for a perfectly balanced photo gallery by nl on Monday August 12, 2013 @08:12AM (#6198751)
Me too, Chrome 28.0.15
Re:The algorithm for a perfectly balanced photo gallery by PavlovsCat on Monday August 12, 2013 @01:18PM (#6200380)
Same for me in FF25 (Aurora), and Opera Next 16.
Re:The algorithm for a perfectly balanced photo gallery by jtreitz on Monday August 12, 2013 @06:42AM (#6198548)
That looks pretty nice too! Congrats on the wedding!
Re:The algorithm for a perfectly balanced photo gallery by wicknicks on Monday August 12, 2013 @12:14PM (#6199968)
Congrats!

The photos didn't appear correctly aligned though -- some 70-100px "whitespace" at the right edge of the screen. And resizing the screen removed all content.

edit: I'm using Firefox v22 on Xubuntu.

Re:The algorithm for a perfectly balanced photo gallery by hobbsy on Monday August 12, 2013 @08:26AM (#6198792)
For me it displayed white rectangles initially - but disabling Adblock extension on Chrome worked (looks great).

However if you then resize the window it seems to make all the images disappear (?)

Re:The algorithm for a perfectly balanced photo gallery by quarterto on Monday August 12, 2013 @11:16AM (#6199644)
It's lazy-loading the images (otherwise, BAM 30MB download). The blank screen thing is the resize handler breaking. I'm looking into it.