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!

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

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>
  • That did it, thanks stranger. – Andrew Parroccini Aug 9 at 0:04
  • Drats, I should have thought of that, of course it's variable pair. GJ Kevin Carpenter – jrothafer Aug 9 at 0:44

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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