Title: Getting Default Values from Shortcode Attributes
Last modified: April 18, 2018

---

# Getting Default Values from Shortcode Attributes

 *  [makkatikki](https://wordpress.org/support/users/makkatikki/)
 * (@makkatikki)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-2/)
 * Hi,
 * I would like to set a default value as input value. How to do that is explained
   in this article
 * [https://contactform7.com/getting-default-values-from-shortcode-attributes/](https://contactform7.com/getting-default-values-from-shortcode-attributes/)
 * The article uses an email input field type to demonstrate how this works.
 * I have tested this and it works fine for email and text fields (probably also
   on some other input types, but I haven’t tested all). So far, so good.
 * Where it does not seem to work is for the input field type **file**.
 * I’ve added the default:shortcode_attr option to my form-tag:
 * `[file* filename default:shortcode_attr]`
 * I then added an attribute with the same name as the field (“filename”) into the
   shortcode for the contact form with value example_image.jpg:
 * `[contact-form-7 id="123" title="Contact Form" filename="example_image.jpg"]`
 * And I’ve added the following code snippet to my theme’s functions.php file:
 *     ```
       add_filter( 'shortcode_atts_wpcf7', 'custom_shortcode_atts_wpcf7_filter', 10, 3 );
       function custom_shortcode_atts_wpcf7_filter( $out, $pairs, $atts ) {
           $my_attr = 'filename';
           if ( isset( $atts[$my_attr] ) ) {
               $out[$my_attr] = $atts[$my_attr];
           }
           return $out;
       }
       ```
   
 * By doing so I would expect to see ‘example_image.jpg’ as value in the file input
   field. But that does not happen. It stays empty.
 * Anyone has an idea why it does not work for input type file and how to make it
   work for input type file?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgetting-default-values-from-shortcode-attributes-2%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘Getting Default Values from Shortcode Attributes’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [default values](https://wordpress.org/support/topic-tag/default-values/)

 * 0 replies
 * 1 participant
 * Last reply from: [makkatikki](https://wordpress.org/support/users/makkatikki/)
 * Last activity: [7 years, 12 months ago](https://wordpress.org/support/topic/getting-default-values-from-shortcode-attributes-2/)
 * Status: not resolved