Documentation > Developers > Filter Examples > Change Proof File Format to .csv

Change Proof File Format to .csv

/**
 * Filter the proof file content, so that images are comma separated
 */
function my_picu_proof_file_content( $proof_file_content, $post_id ) {
	$img_filenames = picu_get_approved_filenames( $post_id );
	$img_filenames = explode( ' ', $img_filenames );
	ob_start();
	
	echo "\"Label\",\"Filename\"\n";
	foreach( $img_filenames as $file ) {
		echo "Proof,$file\n";
	}

	return ob_get_clean();
}

add_filter( 'picu_proof_file_content', 'my_picu_proof_file_content', 10, 2 );

/**
 * Filter file name, use .csv as file extension
 */
function my_picu_proof_file_name( $filename, $post_id ) {
	return 'proof.csv';
}

add_filter( 'picu_proof_file_name', 'my_picu_proof_file_name', 10, 2 );Code language: PHP (php)

Need help?

If you couldn’t find what you were looking for and need more assistance, please get in touch with us directly and we’re happy to help.