This is awesome and works perfectly. Thank you so much!
The only issue I am having is that it only seems to work if the gallery section that I am turing into a block is on the same page. I am hoping to create some "master" gallery sections that I can include in multiple pages on my site and that seems to break the code. Any suggestions?