0

Every entry has one image {event_feature_image_01}, however, some entries have a second, third and forth image. I want to count backwards from the forth image {event_feature_image_04}. Every entry has one image. So that is the {if:else}.

I tried to put in 3 images using {if:else if} but Something is not right in the syntax and I am not sure what it is.

{if event_feature_image_04} <img class="img-responsive osd-border" alt="Photo:{event_name}" src="{event_feature_image_04}" {if:elseif src="{event_feature_image_03}"} {if:else} src="{event_feature_image_01}" {/if}>

Thanks

1 Answer 1

1

Option 1 - show nothing at all if there is no image:

{if  event_feature_image_04 
  OR event_feature_image_03 
  OR event_feature_image_02 
  OR event_feature_image_01}
<img class="img-responsive osd-border" alt="Photo:{event_name}" src="
{if event_feature_image_04}{event_feature_image_04}
{if:elseif event_feature_image_03}{event_feature_image_03}
{if:elseif event_feature_image_02}{event_feature_image_02}
{if:else}{event_feature_image_01}{/if}
">
{/if}

Option 2 - show a default image if no event_feature_image is set:

<img class="img-responsive osd-border" alt="Photo:{event_name}" src="
{if event_feature_image_04}{event_feature_image_04}
{if:elseif event_feature_image_03}{event_feature_image_03}
{if:elseif event_feature_image_02}{event_feature_image_02}
{if:elseif event_feature_image_01}{event_feature_image_01}
{if:else}dummy_image.jpg{/if}
">
2
  • Awesome ... but I forgot that 2 out of the 30 entries don't have images. and now the class show an empty broader with not image inside. [link]osd.seeingishosting.com/index.php/events/show/category/…
    – seeingis
    Commented Mar 11, 2016 at 21:36
  • Ahah. OK. One solution would be to have some overall condition around the <img> tag - so you get nothing appearing if there are no images, but that might mess up your HTML, so an alternative would be to put in a placeholder image if there is no other image set. I've modified the code in answer to account for the two cases... Commented Mar 11, 2016 at 21:41

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.