I'm building my first Craft site and need to set a variable if a field has an image and then use that variable elsewhere in the template.
The field is part of a matrix and will repeat.
What I have so far is:
{# extra image #}
{% set asset = block.extraImage.first() %}
{# set variable empty so it's avialble outside of conditional #}
{% set float = "" %}
{% if asset %}
<img src="{{ asset.url }}" alt="" class="img-responsive pull-right" />
{% set float = yes %}
{% endif %}
<div class="{{ float }}"> more code here </div>
The above code doesn't give me any template errors. But it also doesn't output the class as expected.
The full template code can be viewed here.