Home › Forums › General Issues › How can I set a default image for an image field? › Reply To: How can I set a default image for an image field?
I am not sure you can set a default image.
I think that your template should take care of this for you. I would just setup ACF option with the default image (or define a variable in your template if it’s not something that your client needs to change).
When you are displaying the logo, you can do something like this:
if ( '' === get_field( 'logo' ) {
$image_url = get_field( 'default_image', 'option' );
// Render the default image.
}
Non option version:
$default_image = (your default image URI);
if ( '' === get_field( 'logo' ) {
// Render the default image using $default_image
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.