Support

Account

Home Forums Backend Issues (wp-admin) default image field attachment Reply To: default image field attachment

  • Hi,

    you can use the acf/prepare_field filter for that.
    https://www.advancedcustomfields.com/resources/acf-prepare_field/

    In the function, you first check if the value is null. Only a newly create post will have null, if it’s a saved post that has no value, it’s an empty string.

    
    <?php
    
    add_filter('acf/prepare_field/type=image', 'acf_use_default_image');
    
    function acf_use_default_image($field) {
        if ($field['value'] === null) {
            $field['value'] = 5; // attachment id
        }
    
        return $field;
    }
    

    Cheers 🤗