Lowercase All Filenames

This snippet will automatically lowercase all filenames.

Code

Filename: gpfr-lowercase-all-filenames.php

<?php
/**
 * Gravity Perks // GP File Renamer // Lowercase All Filenames
 * https://gravitywiz.com/documentation/gravity-forms-file-renamer/
 *
 * This snippet will automatically lowercase all filenames.
 */
add_filter( 'gpfr_filename', function( $renamed_file, $file, $entry ) {
	// Important note, $renamed_file is the entire path.
	$lowercase_filename = strtolower( wp_basename( $renamed_file ) );

	return str_replace( wp_basename( $renamed_file ), $lowercase_filename, $renamed_file );
}, 10, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.