Title: raphaello77's Replies | WordPress.org

---

# raphaello77

  [  ](https://wordpress.org/support/users/raphaello77/)

 *   [Profile](https://wordpress.org/support/users/raphaello77/)
 *   [Topics Started](https://wordpress.org/support/users/raphaello77/topics/)
 *   [Replies Created](https://wordpress.org/support/users/raphaello77/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/raphaello77/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/raphaello77/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/raphaello77/engagements/)
 *   [Favorites](https://wordpress.org/support/users/raphaello77/favorites/)

 Search replies:

## Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Image Widget] add new field](https://wordpress.org/support/topic/add-new-field-4/)
 *  [raphaello77](https://wordpress.org/support/users/raphaello77/)
 * (@raphaello77)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/add-new-field-4/#post-5605258)
 * Hmm I did try that filter but something didnt want to work cant remember exactly
   what at the moment.. Ill try it again 🙂
 * What i am trying to do is to add your great image upload feature (that i really
   like!!) and combine it with a woocommerce product listing widget and a custom
   taxonomy selector..
 * Here it is:
    [https://github.com/raphaello77/woocommerce-image-upload-and-product-listing-widget/blob/master/image_product_listing_widget.php](https://github.com/raphaello77/woocommerce-image-upload-and-product-listing-widget/blob/master/image_product_listing_widget.php)
 * I added a whole lot of file extra fields there..
 * PS: Thanks for a really great plugin Brady!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Simple Image Widget] add new field](https://wordpress.org/support/topic/add-new-field-4/)
 *  [raphaello77](https://wordpress.org/support/users/raphaello77/)
 * (@raphaello77)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/add-new-field-4/#post-5605256)
 * I did it like this:
 * first overloaded this class function and added my field extra_field
 *     ```
       public function form_fields() {
       		return array(
       			'image_size',
       			'link',
       			'link_text',
       			'link_classes',
       			'text',
       			'extra_field',
       		);
       	}
       ```
   
 * then used this filter
 *     ```
       add_filter( 'simple_image_widget_instance', function( $instance, $new_instance, $old_instance, $id_base ) {
   
       		$instance['show'] = absint( $new_instance['extra_field'] );
   
       		return $instance;
       }, 10, 4 );
       ```
   
 * then added the input field with this action
 *     ```
       add_action( 'simple_image_widget_field-extra_field', function( $instance, $that ) {
       	?>
       	<p>
       		<label for="<?php echo esc_attr( $that->get_field_id( 'extra_field' ) ); ?>">Extra field</label>
       		<input class="widefat" id="<?php echo esc_attr( $that->get_field_id( 'extra_field' ) ); ?>" name="<?php echo esc_attr( $that->get_field_name( 'extra_field' ) ); ?>" type="number" step="1" min="1" max="" value="<?php echo $instance['extra_field'] ?>">
       	</p>
       	<?php
       }, 10, 2);
       ```
   
 * Workes good and seemed correct atleast..

Viewing 2 replies - 1 through 2 (of 2 total)