3

I'm running into a roadblock here. Basically my client wants to use the "description" field of a file as the alt text, unless it isn't filled out, then he wants it to fall back to the page title. I am using this:

<li class="large-4 small-3 columns">
     {if right_image_1:description }
        {right_image_1}<img class="avatar w-alt" alt="{description}" src="{url}" />{/right_image_1}
    {if:else}
        <img class="avatar wo-alt" alt="{title}" src="{right_image_1}" />
    {/if}
</li>

But it keeps defaulting to the title field no matter what info i have in the description. Any idea what I'm doing wrong?

Thanks!

4
  • Did you try testing against a known value? {if right_image_1:description != ""}
    – jrothafer
    Aug 8, 2018 at 22:13
  • ↑↑↑ What he said ↑↑↑ Aug 8, 2018 at 22:15
  • @jrothafer did that, no change. Aug 8, 2018 at 22:16
  • @jcogs.eecms no change when I do that. Aug 8, 2018 at 22:34

1 Answer 1

6

Try this:

<li class="large-4 small-3 columns">
    {right_image_1}
    {if description}
        <img class="avatar w-alt" alt="{description}" src="{url}" />
    {if:else}
        <img class="avatar wo-alt" alt="{title}" src="{url}" />
    {/if}
    {/right_image_1}
</li>
1
  • Drats, I should have thought of that, of course it's variable pair. GJ Kevin Carpenter
    – jrothafer
    Aug 9, 2018 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.