Support

Account

Home Forums Feature Requests Default Value for Images

Solving

Default Value for Images

    • JboyJW

    • March 12, 2015 at 2:50 am

    I’ve seen one other request for a Default Value for Image types but it was because they needed it for a new type they were adding.

    I’m requesting this feature in general. I don’t see why an Image is any different than other field types in that there can be a default when a new Post is created. Perhaps a default would not be possible when choosing to use an Image Object. But for Image ID and Image URL, there should be a default option so that I can enter the ID or URL of a previous uploaded image.

    For instance, if I make an ACF for a banner image, it would be nice to be able to upload a banner image meant for a default banner, and then use its attachment ID as the default for my field. This makes it so then when a user creates a new post, the default banner is already visible to them and gives them a better idea about if they want to change it or not. It also gives them the option to remove it and have no banner image.

    If I were to just use the template code to show a default image when no image is selected, it eliminates the option of not showing an image.

    Thanks.

    • James

    • April 8, 2016 at 5:45 pm

    Hi @jboyjw,

    Thanks for the feature request.

    The issue has been submitted to Elliot and hopefully this will be added to the plugin’s development roadmap.

    • JboyJW

    • April 8, 2016 at 11:19 pm

    Thanks James. I’ve had a few instances now where this would have been really helpful. Hopefully it gets added to the roadmap.

    Cheers.

  • I came across this while I was looking for something else. Adding a default image setting for all image fields is actually simple to do and a while back I created a filter to do it https://github.com/Hube2/acf-filters-and-functions/blob/master/default-image-for-image-field.php

  • 2 years later – still helping people out ๐Ÿ™‚ Thanks John for the link, works perfectly.

    • tabboy

    • May 17, 2019 at 2:33 pm

    This snippet is important if you want to utilize the default image value in the front end.

    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;
    }
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.