How to filter entries by multiple checkbox field types
Apologies if I’ve misunderstood your question and over-simplified things, but wouldn’t the search() method give you precisely what you need?
As in:
{% set valsToFind = &quot;field_photoColor:red OR field_photoColor:green OR field_photoSubject:animal OR field_photoSize:small&quot; %}
{% set galleries = craft.entries.section(&quot;gallery&quot;).search(valsToFind).all() %}