original_string: public function js_data( $field ) {
  		$value = $field->get_value();
  
  		// Preapre attachment for the preview.
  		$attachment = [];
  
  		// Fake an attachment model - needs all fields used by template.
  		// Note that the default value must be a URL, NOT an attachment ID.
  		if ( ! $value && $_default = $field->get_default() ) {
  			$type = in_array( substr( $_default, -3 ), [ 'jpg', 'png', 'gif', 'bmp' ] ) ? 'image' : 'document';
  
  			$attachment = [
  				'id'    => 1,
  				'url'   => $_default,
  				'type'  => $type,
  				'icon'  => wp_mime_type_icon( $type ),
  				'title' => basename( $_default ),
  			];
  
  			if ( 'image' === $type ) {
  				$attachment['sizes'] = [ 'full' => [ 'url' => $_default ] ];
  			}
  		} elseif ( $value ) {
  			$attachment = wp_prepare_attachment_for_js( $value );
  		}
  
  		return [
  			'mime_type'  => $this->mime_type,
  			'attachment' => $attachment,
  			'labels'     => Arr::only( $this->get_button_labels(), [ 'frame_title', 'frame_button' ] ),
  		];
  	}
code: public function js_data( $field ) {
  		$value = $field->get_value();
  
  		// Preapre attachment for the preview.
  		$attachment = [];
  
  		// Fake an attachment model - needs all fields used by template.
  		// Note that the default value must be a URL, NOT an attachment ID.
  		if ( ! $value && $_default = $field->get_default() ) {
  			$type = in_array( substr( $_default, -3 ), [ 'jpg', 'png', 'gif', 'bmp' ] ) ? 'image' : 'document';
  
  			$attachment = [
  				'id'    => 1,
  				'url'   => $_default,
  				'type'  => $type,
  				'icon'  => wp_mime_type_icon( $type ),
  				'title' => basename( $_default ),
  			];
  
  			if ( 'image' === $type ) {
  				$attachment['sizes'] = [ 'full' => [ 'url' => $_default ] ];
  			}
  		} elseif ( $value ) {
  			$attachment = wp_prepare_attachment_for_js( $value );
  		}
  
  		return [
  			'mime_type'  => $this->mime_type,
  			'attachment' => $attachment,
  			'labels'     => Arr::only( $this->get_button_labels(), [ 'frame_title', 'frame_button' ] ),
  		];
  	}
code_tokens: public function js_data ( $ field ) { $ value = $ field -> get_value ( ) ; // Preapre attachment for the preview. $ attachment = [ ] ; // Fake an attachment model - needs all fields used by template. // Note that the default value must be a URL, NOT an attachment ID. if ( ! $ value && $ _default = $ field -> get_default ( ) ) { $ type = in_array ( substr ( $ _default , - 3 ) , [ 'jpg' , 'png' , 'gif' , 'bmp' ] ) ? 'image' : 'document' ; $ attachment = [ 'id' => 1 , 'url' => $ _default , 'type' => $ type , 'icon' => wp_mime_type_icon ( $ type ) , 'title' => basename ( $ _default ) , ] ; if ( 'image' === $ type ) { $ attachment [ 'sizes' ] = [ 'full' => [ 'url' => $ _default ] ] ; } } elseif ( $ value ) { $ attachment = wp_prepare_attachment_for_js ( $ value ) ; } return [ 'mime_type' => $ this -> mime_type , 'attachment' => $ attachment , 'labels' => Arr :: only ( $ this -> get_button_labels ( ) , [ 'frame_title' , 'frame_button' ] ) , ] ; }
docstring: Returns field data for the JS.
  
  @param \WPLibs\Form\Field $field
  @return array
docstring_tokens: Returns field data for the JS .