title: Custom widget Image upload Issue
body: <p>A day before tomorrow, I developed a custom widget for my Recent WordPress theme. In that widget, have an image upload field with some other fields. I have done everything and the widget is working very well except one problem. When I am dragging the widget in sidebar and giving the information needed in all fields, its showing fine in front-end. But after that when I am trying to change the image from that widget back-end then the save button remain saved. Image doesn’t change.</p>
  
  <p>Codes are below:</p>
  
  <pre><code>            class Themeslug_About_Widget extends WP_widget{
  
  
  
                 public function __construct(){
  
                          parent::__construct('author_info', esc_html__( 'About Info Box', 'blogista' ), array(
  
                          'description' =&gt; esc_html__( 'About Info Box contain brief about Author/ Company.', 'blogista' ),
  
                                  ));
  
                          }
  
                  public function widget( $args, $instance ){
  
  
                          echo $args['before_widget'];
                              echo $args['before_title'] . $instance['title'] . $args['after_title'];
                              ?&gt;
                              &lt;img src="&lt;?php echo $instance['author_box_image']; ?&gt;" alt="&lt;?php echo $instance['title']; ?&gt;" /&gt;
                              &lt;div class="widget-content"&gt;
  
                                  &lt;h3 class="title"&gt;
                                      &lt;a href="#"&gt;&lt;?php echo $instance['author_name']; ?&gt;&lt;/a&gt;
                                  &lt;/h3&gt;
  
  
  
  
                              &lt;/div&gt;
                          &lt;?php           
                          echo $args['after_widget'];
  
  
  
                      }
  
                  public function form( $instance ){
  
                          $title = '';
                          if( !empty( $instance['title'] ) ) {
                              $title = $instance['title'];
                          }
  
  
                          $author_box_image = '';
  
                          if( ! empty( $instance['author_box_image'] ) ) {
                              $author_box_image = $instance['author_box_image'];
                          }
          ?&gt;
  
                              &lt;p&gt;
                                  &lt;label for="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"&gt;&lt;?php _e( 'Title:', 'blogista' ); ?&gt;&lt;/label&gt;
                                  &lt;input type="text" value="&lt;?php echo esc_attr( $title ); ?&gt;" name="&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;" id="&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;" class="widefat"&gt;
                              &lt;/p&gt;
  
                              &lt;p&gt;
                                  &lt;button class="button button-primary" id="author_info_image"&gt;&lt;?php _e( 'Upload Image', 'blogista' ); ?&gt;&lt;/button&gt;
                                  &lt;input type="hidden" name="&lt;?php echo $this-&gt;get_field_name('author_box_image'); ?&gt;" id="&lt;?php echo $this-&gt;get_field_id('author_box_image'); ?&gt;"  class="image_link"  value="&lt;?php echo esc_url( $author_box_image ); ?&gt;" &gt;
                                  &lt;div class="image_show"&gt;
                                      &lt;img src="&lt;?php echo $instance['author_box_image']; ?&gt;" width="200" height="auto" alt=""&gt;
                                  &lt;/div&gt;
                              &lt;/p&gt;
  
  
  
                          &lt;?php
  
                      }
  
                  public function update( $new_instance, $old_instance ) {
  
                      $instance = array();
  
                      $instance['title']              = ( ! empty( $new_instance['title'] ) ) ? esc_attr( $new_instance['title'] ) : '';
                      $instance['author_box_image']   = ( ! empty( $new_instance['author_box_image'] ) ) ? esc_url( $new_instance['author_box_image'] ) : '';
  
  
                      return $instance;
  
                  }
  
  
  
      }
  
  
  
  
  
      function themeslug_admin_enqueue_scrits(){
  
          wp_enqueue_media();
  
          wp_enqueue_script( 'admin_custom_script', get_theme_file_uri() . '/js/libs/admin_scripts.js', array( 'jquery' ), '1.0', true );
  
  
  
      }
  
  add_action( 'admin_enqueue_scripts', 'themeslug_admin_enqueue_scrits' );
  </code></pre>
  
  <p>Then added the below jQuery code:</p>
  
  <pre><code>(function($){
  
  
      $(document).ready(function(){
          $('button#author_info_image').on("click",function( e ){
  
              e.preventDefault();
  
  
  
  
              var imageUploader = wp.media({
  
                  'title' : 'Upload Author Image',
                  'button'    : {
                      'text' : 'Set The Image'
                  },
                  'multiple' : false
  
              });
  
  
              imageUploader.open();
  
  
              imageUploader.on("select", function(){
                  var image = imageUploader.state().get("selection").first().toJSON();
  
                  var link = image.url;
  
                  $("input.image_link").val( link );
  
                  $(".image_show img").attr('src', link);
  
              });
  
  
          });
      });
  
  
  
  
  }(jQuery))
  </code></pre>
  
  <p>Every thing is working fine first time but when trying to change the image then Widget save button remain saved.
  Please Help.</p>
  
  <p>Thanks in Advance.</p>