Only executing if a matrix checkbox has a specific value I currently have checkboxes in a matrix block that allow a user to select where an image will be placed in the layout (as a featured slider image and/or in an image gallery). I've gotten the slider image to function but if, for some reason, there are no featured images I have a couple of unnecessary &lt;div&gt; tags. Because I am selecting only featured images from the matrix block I can not use loop.first and loop.last to move those divs in my for loop. 

I had seen an article that seems close to finding the answer to my problem here : Only execute twig block if a Matrix radio has a certain value but I haven't been able to make it work. 

Any help would be greatly appreciated.

{# Add Feature Images - Slideshow #}
    {% set photos = entry.photoGallery.type( 'photos' ) %}
    {% if photos|length %}
    &lt;div class="row" &gt;
            &lt;div class="slidr"&gt;
                {% for block in photos if block.imageLocation.contains('featured')%}
                    {# Get the photo #}
                    {% for photo in block.photo %}
                      &lt;div class="figure"&gt;
                        &lt;a href="{{ photo.getUrl }}"&gt;
                          &lt;img src="{{ photo.getUrl('projectHero') }}" alt=""&gt;
                        &lt;/a&gt;
                        {# Get the caption #}
                        {% if block.caption|length %}
                          &lt;div class="caption"&gt;{{ block.caption }}&lt;/div&gt;
                        {% endif %}
                      &lt;/div&gt;
                    {% endfor %}
                {% endfor %}
            &lt;/div&gt;
    &lt;/div&gt;
    {% endif %}


I've attached a screen snapshot of my field setup.
{% if block.checkboxFieldHandle.contains('someChkbxValue') %}
&lt;p&gt;Executed!&lt;/p&gt;
{% endif %}


actual for Craft v2.x and v3.x