File Renaming on Upload

Description

Have you ever had any problems uploading files with accents and some special characters to WordPress? Probably the answer is yes.

This plugin will help you fixing this problem by renaming these files on upload. Besides that, you can improve your SEO and have a better control of your filenames.

Screenshots

  • An exemple of a sanitized filename in Media Library
  • On general settings, setup how your filename will be, using the filename structure option where you have some rules at your disposal
  • Setup how the rules will work on your filename

Installation

  1. Upload the entire ‘file-renaming-on-upload’ folder to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Start by visiting plugin settings at Settings > File Renaming

FAQ

Installation Instructions
  1. Upload the entire ‘file-renaming-on-upload’ folder to the ‘/wp-content/plugins/’ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Start by visiting plugin settings at Settings > File Renaming
What are the available options provided by this plugin?

For now, you can choose these options:

  • Add Site url: Inserts “yoursite.com” at the beggining of the file name. Ex: yoursite.com_filename.jpg. It is good for your SEO

  • Post title: If you are on a post edit page called “Spiderman will leave Marvel” and you upload a jpg it will be called spiderman-will-leave-marvel-my-file.jpg. This option allows you to replace filename by post title or add the post title.

  • Remove characters: Remove any characters you want from filename

  • Datetime: You can add or replace filename by Datetime in any format you want

  • Lowercase: Converts all characters to lowercase

  • Remove accents

  • Update permalink: When the filename is changed, you can also change its permalink if you want

How does this plugin work?

It renames files on upload using the available rules. More specifically, it uses some filters provided by WordPress to handle file name sanitizing, like sanitize_file_name, sanitize_file_name_chars or actions like add_attachment

What are rules?

Rules are options to control how your filename will be. Rules are enabled on the rules tab and have to be placed on the filename scructure option

What is filename structure option for?

It’s the option where you can put your rules or any other characters you want to set how your filename will be

Are there any hooks available?

Yes, you can use the filter frou_sanitize_file_name to create custom rules. See the next item below

Can i create a custom rule?

Yes. It’s easy.

First, you have to create a custom rule in the filename structure option using curly braces, like {my_custom_rule}. You just have to write it, in any position you want.

Now you can use the filter frou_sanitize_file_name to create a custom function. For example, if you want to put the user id it would be something like this:

add_filter( 'frou_sanitize_file_name', function($filename_infs){
    $filename_infs['structure']['translation']['my_custom_rule'] = get_current_user_id();
    return $filename_infs;
}, 20 );
How can i contribute with code development?

Head over to the File Renaming on Upload plugin GitHub Repository to find out how you can pitch in

Reviews

This Plugin is one of the golden Nuggets

Hi Pablo!

Just discovered your Plugin. I searched for a long time to resolve Issues with special Chars in German Language (ä,ö,ü,ß space, special chars) when my Authors uploaded their Images 🙂

Now your Plugin works beside Imsanitiy and Frontend Publisher Pro and saves me a lot of time. Since today I had to control and to edit this files manually.

With best regards,
Karl, Austria

Great Plugin

A great plugin with awesome support that can be part of WordPress core.

Useless because it doesn’t change permalinks

Hello,

Just my two cents, but why make a plugin like this if the permalinks aren’t updated? It’s just useless to rename a file and having 404 errors because permalinks are wrong.

Do you plan to implement a such features in order to edit my review or not?

Read all 17 reviews

Contributors & Developers

“File Renaming on Upload” is open source software. The following people have contributed to this plugin.

Contributors

“File Renaming on Upload” has been translated into these 2 locales: German, Brazilian Portuguese. Thank you to the translators for their contributions.

Translate “File Renaming on Upload” into your language.

Interested in development?

Browse the code or subscribe to the development log by RSS.

Changelog

2.1.4

  • Fix conflict on WeDevs settings API libraries

2.1.3

  • Update Settings API class

2.1.2

  • Start the plugin after plugins_loaded hook
  • Fix github link
  • Improve readme

2.1.1

  • Add new option to ignore filenames
  • Fix conflict with sitemap.xml generated by All in one SEO pack

2.1.0

  • Add new option to remove non ASCII characters

2.0.8

  • Solve more conflicts with github updater plugin

2.0.7

  • Fix datetime option fatal error on update() boolean

2.0.6

  • Solves more conflicts with github updater plugin

2.0.5

  • Ignores more basenames (‘option_page’, ‘action’, ‘wpnonce’, ‘wp_http_referer’, ‘github_updater_repo’, ‘github_updater_branch’, ‘github_updater_api’, ‘github_access_token’, ‘bitbucket_username’, ‘bitbucket_password’, ‘gitlab_access_token’, ‘submit’, ‘db_version’, ‘github_updater_install_repo’) when there is no extension provided to solve more conflicts with github-updater plugin

2.0.4

  • Ignores some basenames (‘path’, ‘scheme’, ‘host’, ‘owner’, ‘repo’, ‘owner_repo’, ‘base_uri’, ‘uri’) when there is no extension provided. It solves conflicts with github-updater plugin

2.0.3

  • Improve description
  • Add option to ignore renaming for some filename extensions
  • Add new screenshot
  • Remove portuguese and german translation packs from languages folder

2.0.2

  • Improve Portuguese translation
  • Add German translation

2.0.1

  • Fix autoloader bug on linux environments

2.0.0

  • Recreate the plugin with some new options

1.3

  • Fix bug where site url should be home url instead

1.2

  • Added an option to renames files based on post title
  • Fixed a bug where some strings were not properly removed from site url

1.1

  • Added an option to remove string parts from url

1.0.1

  • Admin page class renamed

1.0

  • Initial release