I have an image that is an optional channel field, and I've got it hard coded into the template. If someone doesn't attach an image, there is an empty image box on the page for that entry. How can I tell EE to check for an image, and if its not there, just load the rest of the page normally?

1 Answer 1


I think this should work:

In this example I use three custom fields: article_image, image_description and class.

{if article_image != ""}
   <img src="{article_image}" alt="{image_description}" title="{image_description}" class="{class}" />

You can also use the shorthand version of the above code like so "{if custom_field}content here{/if}". This shortens up the code a bit.

  • There is a {} button in the editor, or simply indent it by four spaces (we use markdown formatting) Jan 6, 2013 at 0:15

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.