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' ] ),
		];
	}
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' ] ),
		];
	}
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' ] ) , ] ; }
Returns field data for the JS.

@param \WPLibs\Form\Field $field
@return array
Returns field data for the JS .