In depth look at the images field type

Posted 27th Oct 2017

#fields #images

We'll create a simple template and hold the default image on that to demonstrate.

Admin > Setup > Templates

Create a template which will store the field for your default image. In this example, I have an image field which holds a single image called 'featuredImage', so I'll add that to the template. I changed the field label to 'Default featured image' as a reminder of what this field is for.

Site settings template
Site settings template Zoom

Create a page called 'Site settings'.

Creating the site settings page
Creating the site settings page Zoom

Edit the page and upload a default image.

Site settings page with default image
Site settings page with default image Zoom

Admin > Setup > Fields > Details (tab)

Edit the 'featuredImage' field and choose the 'site-settings' page we created earlier as the default location for the default image of this field.

Setting default image on the featuredImage field
Setting default image on the featuredImage field Zoom

Now, if you have this field empty on any other templates and you render it, you get the default image.

Of course, you don't need to go to the trouble of creating a template to hold a default image, you can just choose any page that has this field on it. But if you go this route, make sure the field actually has an image in! Thiis is why I the site-settings template approach for all things default. You can keep all kinds of other stuff in there too for your site, the logo image, email addresses, social media links, whatever. You can check out this post on using a site-settings template for more ideas.

Feedback & support

I hope you enjoyed this tutorial. You can support pwtuts by following on @pwtuts. You can also donate at paypal.me/swcarrey to help support the site which would be awesome!

Related tutorials / See all

Suggest a tutorial

Please note: I do not store any of this information, it's simply used to send me an email. Your email address is required so I can get clarification on your request if needed.