I was running into the same issue and this code worked perfectly. As a follow up I was wondering if anyone knows how I could add a little more vertical space between the gallery images while in mobile view? It currently looks like this.
I was just running into the same issue (trying to figure out how to link portfolio pages to an external weblink when you click on them). Wondering if anyone knows the code that I would need to achieve this.