Support

Account

Home Forums General Issues auto load default images to front

Solved

auto load default images to front

  • with the help of this forum i succeeded in building acf form with a default image.
    the acf form is connected to a custom post type and the values are being
    Filled by the user from the front end with gravity forms.
    the form content needs to be shown in a different page.
    every thing is good with the user data and the info is showing fine.
    the problem is that the default image i set and is not loaded automatically.
    instead i need to enter to the post and update the post.
    how can i make the image to be uploaded automatically to the front end.

    my default image code:

    
    // Add Default Image Setting to Image Field ACF
    
    add_action('acf/render_field_settings/type=image',
               'add_default_value_to_image_field', 20);
    function add_default_value_to_image_field($field) {
      $args = array(
        'label' => 'Default Image',
        'instructions' => 'Appears when creating a new post',
        'type' => 'image',
        'name' => 'default_value'
      );
      acf_render_field_setting($field, $args);
    }
    
    // Reset Default Image
    
    add_filter('acf/load_value/type=image', 'reset_default_image', 10, 3);
    function reset_default_image($value, $post_id, $field) {
      if (!$value) {
        $value = $field['default_value'];
      }
      return $value;
    }
    
  • I chose a different approach

  • I’m running into the same problem as you.. which approach did you use?

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘auto load default images to front’ is closed to new replies.