0

I'm sure this is a basic question (EE is not my bag): I am trying to create a fallback for an image's alt text where if the image does not have a description then to use the title of the entry in its place.

But obviously if I use

{image}
  <img src="{url}" alt="{if description}{description}{if:else}{title}{/if}"> 
{/image}

Then it uses the image's title.

How do I make it display the entry title instead?

TIA.

0

Can you give me a little more information about your code here?

{image} is a grid field? What fields does the grid have? Perhaps you could rename the {title} field in your grid to something that doesn't overwrite the default {title} field?

| improve this answer | |
0

Are you using the file fieldtype..if so with the variable pair tag.. i guess you can't get the entry title!??.. But if you have only 1 image.. you may try something like..

{image limit="1"} <img src="{url}" alt="{if description}{description}"{/image}{if:else}{/image}{title}"{/if}> It's not elegant.. and i didn't test it.. !

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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