Adding class based on length
I figured it out by modifying the code from this answer on image transforms. Here's the basics of my markup.

&lt;div class="{% if loop.length == 2 %}grid-one-half{% elseif loop.length == 3 %}grid-one-third{% elseif loop.length == 4 %}grid-one-quarter{% endif %} grid-item"&gt;
&lt;/div&gt;