Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Can I set a Default Image for ImageField?

Go to End

4 Posts   2475 Views


Community Member, 191 Posts

30 September 2008 at 1:52pm

Edited: 03/10/2008 4:48pm

No one has responded yet, so let me elaborate. I have an ArticlePage (radio show) that will have a Title, Image, Audio File, and Description. I have set the CMS up with a new ImageField, but for times that the client doesn't have a photo, I would like to set a default image. Any help would be appreciated.

Thank You,


Community Member, 191 Posts

3 October 2008 at 4:50pm

Is this possible? Is there a different approach that anyone can think of?


Community Member, 244 Posts

3 October 2008 at 5:05pm

Edited: 03/10/2008 5:05pm


the easiest way to do this would be to check if the image exists in the template, rather than inside the CMS (i dont think its supported). To do display a default image if one isnt provided, you can put this in your template:

<% if Image %>
<% else %>
    <img src="assets/default-image.jpg" alt="Default Image"/>
<% end_if %>


Community Member, 191 Posts

3 October 2008 at 5:19pm

Just tried your suggestion, it worked!

thank you!