Convert WordPress Image Filename To Lowercase

WordPress by default will preserve capitalisation in filename for images. To make filenames lowercase automatically, add the following to the functions.php of your active theme.

 * Convert filename to lowercase
 * @author Arun Basil Lal
 * @refer
function prefix_convert_filename_to_lowercase( $file ) {
	$image_extensions = array (
		'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/tiff', 'ico'
	// Return if file is not an image file
	if ( ! in_array($file['type'],$image_extensions) ) {
		return $file;
	$image_extension = pathinfo( $file['name'] );
	$image_name 	 = strtolower( $image_extension['filename'] );
	$file['name'] 	 = $image_name . '.' . $image_extension['extension'];
	return $file;
add_filter('wp_handle_upload_prefilter', 'prefix_convert_filename_to_lowercase', 20 );
Hello, I am Arun Basil Lal. Thank you for reading!

I am a WordPress product developer and creator of Image Attributes Pro. I am passionate about solving problems and travelling the world.

Divi WordPress Theme - My Review

Divi WordPress Theme
Divi is a WordPress theme that web designers do not want you to know. It comes with a drag-and-drop theme builder. You can build beautiful looking unique websites without touching a line of code. Just choose from one of the many pre-made layouts, or pick elements and arrange them any way you like.

Divi is every WordPress developer's wet dream. Surprise your clients with neat responsive websites and have fun building them.

Divi comes from Elegant Themes. If you enjoy building websites, you *need* an Elegant Themes membership. 87 beautiful themes and 5 plugins for the cost of less than a candy-bar each!

Note: I am an avid user of Divi myself and this is a honest review. I wouldn't recommend something that I do not personally find amazing.

Leave a Reply

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