Skip to content

wpcodefactory/file-renaming-on-upload

Repository files navigation

=== Rename Media Files: Improve Your WordPress SEO ===
Contributors: wpcodefactory, omardabbas, karzin, anbinder, algoritmika, kousikmukherjeeli
Tags: rename, seo, media, renaming, characters
Requires at least: 4.0.0
Tested up to: 6.5
Requires PHP: 5.3
Stable tag: 2.5.7
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Enhance SEO and organize media effortlessly with Rename Media Files WordPress Plugin. Fix upload issues, santize & optimize filenames, and improve SEO seamlessly.

== Description ==

> “One of the most important plugins on our site: Perfect plugin for our free stock photo website picjumbo. We’re using it for years to automatically rename our P001120.jpg photos to SEO-focused names like business-woman-using-a-computer-free-photo.jpg. This plugin really works! Thanks!” – ⭐⭐⭐⭐⭐  [viktorhanacek](https://wordpress.org/support/topic/one-of-the-most-important-plugins-on-our-site/)

[Main Page](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme "Main Page") | [Support Forum](https://wpfactory.com/support/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme "Support Forum") | [Documentation & How to](https://wpfactory.com/docs/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme?utm_source=wporg&utm_medium=organic&utm_campaign=readme "Documentation & How to")

The "Rename Media Files: Improve Your WordPress SEO" plugin will simplify the process of managing media file names (images, PDFs, etc) and metadata, ensuring a tidy and search engine-friendly media repository.

If you're an SEO guru and would like to make a better website for search engines by focusing on Image SEO, or someone who enjoys their files to be perfectly organized, this plugin will turn your dreams into reality.

The plugin comes with several features, like the ability to remove accents and special characters from filenames upon upload, rename files based on post titles, Site URL, or current date, and update file permalinks accordingly.

The Pro version goes much further, with features like manual filename and permalink editing, updating old media references in post content, and automatic alt tag generation, the possibilities for optimizing your media library are endless

## 🚀 Main Features: FREE Version##

### 🚀 Remove Accents & Special Characters from Filenames on Upload ###

Ensure clean and SEO-friendly filenames by automatically removing accents and special characters upon upload, this is very useful when you share these files on social media, so you have standard URL without non-friendly characters.

**Example 1:**
A file named "café.jpg" would be renamed to "cafe.jpg".

**Example 2:**
A file named "résumé.pdf" would be renamed to "resume.pdf".

### 🚀 Rename Media on Upload Based on The Site URL ###

Automatically rename uploaded files based on your site URL (domain name) to maintain consistency and relevance between your domain name, content, and media.

**Example 1:**
If your site URL is "example.com," and you uploaded an image named camera.jpg, you can automatically rename it to "example-com-camera.jpg".

**Example 2:**
You can append the site URL to other variables, like post name and/or file name, so for a site URL like "mywebsite.com" uploaded to a post named "how to create a site", a file might be renamed to "mywebsite-com-how-to-create-a-site.jpg".

### 🚀 Rename Media on Upload Based on Post Title ###

Automatically rename uploaded files based on the post title it was uploaded to, this helps in keeping your media & content aligned & consistent.

**Example 1:**
If you upload an image for a post titled "Exploring the Great Outdoors," the file could be renamed to "exploring-the-great-outdoors.jpg".

**Example 2:**
When images with identical names are uploaded to the same post, media name will be appended by a number, so in example 1 it will become "exploring-the-great-outdoors-1.jpg", and this can be customized as well.

### 🚀 Rename Media on Upload Based on The Current Date ###

Instead of the default categorization of media by WordPress (year & month), you can fully control what part of the date you want to include in your media names.

**Example 1:**
An image named "laptop-at-night.webp" uploaded on April 15, 2024, could be renamed to "laptop-at-night-2024-04-15.jpg".

**Example 2:**
You can go further and utilize other rules as well, so you can include site name, post title, file name, and finish it with a date, so you can have a file named "dog.jpg", uploaded to a post title "Nice Dogs", on a website named "Dogs for Life" and uploaded on May 28, 2024, the result file name could be "dogs-for-life-com-nice-dogs-dog-2024-05-28.jpg".

### 🚀 Update Media Permalink Based on Media Rename ###

Media file names might change, but permalinks don't (probably that's why they called so?), with this plugin you can maintain consistency between filenames and permalinks by automatically updating file permalinks based on media renaming actions.

### 🚀 Convert Filename Characters to Lowercase ###

Standardize all media & files characters on your website to lowercase for consistency, to ensure uniformity across your media library & reduce the risk of errors (if redirects weren't properly handled).

### 🚀 Advanced File Filtering Options ###

Customize file renaming behavior with advanced filtering options. Choose to ignore files with no extensions, specific file extensions, or filenames containing certain strings.

> “Does the trick!: We needed a plugin to change the file name of images being uploaded to our site to a 100% predicable URL based on post slug and custom fields. This super simple plugin does the trick! The developer is super responsive and helpful too. We’re glad to have got the pro version.” – ⭐⭐⭐⭐⭐ [russs95](https://wordpress.org/support/topic/does-the-trick-86/)

> “Very handy: Install the plugin, check some simple settings, forget about it because the job will now be done. Thank you very much! 🙂” – ⭐⭐⭐⭐⭐ [wpguillaume](https://wordpress.org/support/topic/very-handy-210/)

## 🏆 Do More: PRO Version##

For those who would like to go further and beyond, we have a premium version of [Rename Media Files: Improve Your WordPress SEO](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme) plugin.

### 🏆 Rename Media on Upload Based on ANYTHING ###

Other than the above options, the plugin allows you to include any of these values in media file renaming rules:

* Datetime
* Upload date
* Custom string
* Post Slug
* User ID
* User Role
* Username
* Product SKU
* Post ID

### 🏆 Edit Media Filenames & Permalinks Manually ###

Take full control over your media library by manually editing filenames and permalinks to match your specific requirements.

### 🏆 Update Old/Previously Uploaded Media ###

You liked how the plugin works and want to apply it for all previous files? Easily update all your media library by updating outdated media files with new filenames and permalinks.

### 🏆 Update Media Reference in post content on file renaming ###

Ensure a seamless integration between media files and post content with this option, so when a media file is renamed, this feature automatically updates all references to that file within post content and  prevents broken links or missing media elements in your website.

### 🏆 Rename (convert) Media Images Extension from JPEG to JPG ###

As "jpg" is the standard file extension for JPEG images, this feature automates converting images with  JPEG extension to the more widely recognized JPG format.
 
### 🏆 Update Filename on Post Update ###

Automatically synchronize media file names with post updates, so that you ensure media files remain aligned with their corresponding content.

### 🏆 Restrict Media File Renaming by User Role ###

Control access to media file renaming options & rules based on user roles of your website, so you guarantee that only authorized users have access to modification tools.

### 🏆 Restrict Media File Renaming by Custom Post Type ###

For those who want to have more control on media update based on the post type, the plugin allows media file renaming options to specific custom post types, such as: post, page, attachment, revision, nav_menu_item, product, product_variation, shop_order, shop_refund, and more!

### 🏆 Images SEO: ALT Texts & Media Titles Naming Automation ###

Take your Image SEO optimization to new levels by automatically generating ALT texts & images titles for images. 

When uploading media files, the plugin offers options to auto-fill both ALT text and image title based on predefined settings or the original filename. For example, if you upload an image named "sunset.jpg," the ALT tag and media title can be auto-filled with "Sunset Image," ensuring that both are descriptive and optimized for accessibility and search engine visibility. 

### 🏆 Compatibility with 3rd Party Plugins ###

* [**Buddyboss**](https://www.buddyboss.com/platform/ "Buddyboss"): Disables profile upload renaming
* [**Gravity forms**](https://www.buddyboss.com/platform/ "Gravity forms"): Handles issues with Gravity Forms entry exports
* [**WPForms**](https://wpforms.com/ "WPForms"): Handles issues with WPForms file upload

___
## ❤️ User Testimonials: See What Others Are Saying!##

> “Perfect plugin for our free stock photo website picjumbo. We're using it for years to automatically rename our P001120.jpg photos to SEO-focused names like business-woman-using-a-computer-free-photo.jpg. This plugin really works! Thanks!” – ⭐⭐⭐⭐⭐ [viktorhanacek](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme)

> “This is really well done. No more telling clients to sanitize file names upfront.
It also creates the correct two-letter form of the German umlauts äöüß -> ae oe ue ss.
Perfect!” – ⭐⭐⭐⭐⭐ [DuchschererM](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme)

> “superb plugin, fantastic support.” – ⭐⭐⭐⭐⭐ [amanrajveer](https://wpfactory.com/item/file-renaming-on-upload-wordpress-plugin/?utm_source=wporg&utm_medium=organic&utm_campaign=readme)

> “Must have plugin!: As WP-Expert i can tell you that this became one of my must have plugins! Wish i discovered this great plugin earlier! Perfect for converting customers weird filenames and improving search engine results.” – ⭐⭐⭐⭐⭐ [nicmare](https://wordpress.org/support/topic/must-have-plugin-231/)

___
## 💯 Why WPFactory?##

* **Experience You Can Trust:** Over a decade in the business
* **Wide Plugin Selection:** Offering 65+ unique and powerful plugins
* **Highly-Rated Support:** Backed by hundreds of 5-star reviews
* **Expert Team:** Dedicated developers and technical support at your service

## What's Next? Discover More Plugins by WPFactory ##

WPFactory has a diverse range of plugins tailored to enhance your experience:

* [**EAN, UPC, ISBN Generator: Product Barcode Inventory for WooCommerce**](https://wpfactory.com/item/ean-barcodes-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**EAN, UPC, ISBN Generator: Product Barcode Inventory for WooCommerce***"): Manage GTINs (EAN, UPC, ISBN, etc.) effortlessly in WooCommerce! Create, save, search, and display EANs easily, with admin tools for bulk actions.
 (**[Free version](https://wordpress.org/plugins/ean-for-woocommerce/ "Free version")**)

* [**Wishlist for WooCommerce: Multi Wishlists per Customer**](https://wpfactory.com/item/wish-list-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Wishlist for WooCommerce: Multi Wishlists per Customer**"): Increase loyality & sales by allowing customers to add products to wishlist, create multiple wishlists, save them, share them with friends & family on your WooCommerce store (**[Free version](https://wordpress.org/plugins/wish-list-for-woocommerce/ "Free version")**)

* [**Name Your Price: Make a Price Offer for WooCommerce**](https://wpfactory.com/item/price-offers-for-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "*Name Your Price: Make a Price Offer for WooCommerce**"): Allow customers to propose their own prices for your products, open a negotiation-driven shopping experience with options to accept, reject, or counter-offer. (**[Free version](https://wordpress.org/plugins/price-offerings-for-woocommerce/ "Free version")**)

* [**Additional Custom Emails for WooCommerce**](https://wpfactory.com/item/custom-emails-for-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Additional Custom Emails for WooCommerce**"): Define & customize more emails based on triggers, choose from multiple recipient options, personalize content, and send emails manually.(**[Free version](https://wordpress.org/plugins/custom-emails-for-woocommerce/ "Free version")**)

* [**Automated Order Status Controller for WooCommerce**](https://wpfactory.com/item/order-status-rules-for-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Automated Order Status Controller for WooCommerce**"): Change order statuses programmatically based on a wide range of conditions, like time intervals, user roles and more! (**[Free version](https://wordpress.org/plugins/order-status-rules-for-woocommerce/ "Free version")**)

* [**Custom Order Status for WooCommerce**](https://wpfactory.com/item/order-status-for-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Custom Order Status for WooCommerce**"): Create & manage unlimited number of custom statuses, to reflect your business desires & needs. (**[Free version](https://wordpress.org/plugins/order-status-for-woocommerce/ "Free version")**)

* [**Free Shipping Over Amount for WooCommerce**](https://wpfactory.com/item/amount-left-free-shipping-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Free Shipping Over Amount for WooCommerce**"): Encourage higher spending by offering free shipping based on amount, with a progress bar for customers (**[Free version](https://wordpress.org/plugins/amount-left-free-shipping-woocommerce/ "Free version")**)

* [**Dynamic Pricing & Bulk Quantity Discounts**](https://wpfactory.com/item/product-price-by-quantity-for-woocommerce/?utm_source=wporg&utm_medium=organic&utm_campaign=readme "**Dynamic Pricing & Bulk Quantity Discounts**"): Advanced dynamic pricing and discount rules for WooCommerce, encouraging bulk purchases and driving more sales (**[Free version](https://wordpress.org/plugins/wholesale-pricing-woocommerce/ "Free version")**)


== Frequently Asked Questions ==
= 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?
* **frou_sanitize_file_name** Creates custom rules. Take a look on (Can I create a custom rule?)
* **frou_ignored_extensions** Ignores extensions. Take a look on (How to ignore extensions programmatically?)

= How to ignore extensions programmatically?
You can use the **'frou_ignored_extensions'** filter to ignore extensions programmatically.
For example, if you'd like to ignore txt, js and zip extensions:

`add_filter( 'frou_ignored_extensions', function ( $extensions ) {
	$extensions = array_merge( $extensions, array(
		'txt',
		'js',
		'zip',
	) );
	return $extensions;
} );`

= 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](https://github.com/pablo-sg-pacheco/file-renaming-on-upload) to find out how you can pitch in

== 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

== Screenshots ==

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

== Changelog ==

= 2.5.7 - 2024/04/25 =
* Tested up to: 6.5.

= 2.5.6 - 2023/09/26 =
* Tested up to: 6.3.
* Update plugin icon, banner.

= 2.5.5 - 2023/06/30 =
* Fix - Sanitize multiselect fields properly.

= 2.5.4 - 2023/06/20 =
* Dev - New filter: `frou_get_parent_post_title`.

= 2.5.3 - 2023/05/18 =
* Fix - PHP warning: Trying to access array offset on value of type int.

= 2.5.2 - 2023/05/18 =
* Fix - Fields are not getting sanitized properly.
* Dev - Improve separator logic.
* Tested up to: 6.2.

= 2.5.1 - 2023/02/01 =
* Tested up to: 6.1.
* Move to WPFactory.

= 2.5.0 - 2022/08/12 =
* Tested up to: 6.0.

= 2.4.9 - 2022/02/21 =
* Improve "Convert characters to dash" option.
* Tested up to: 5.9.

= 2.4.8 - 2021/10/14 =
* Add "Max length" option for "Filename structure".

= 2.4.7 - 2021/09/20 =
* Fix - Both plugins can't be active at the same time.
* Improve composer setup.
* Improve readme.
* Tested up to: 5.8.

= 2.4.6 - 2021/07/02 =
* Fix timezone warning from datetime rule.
* Add `frou_current_media_id` filter.
* Add `get_current_media_id()` function.

= 2.4.5 - 2021/06/07 =
* Save original filename on new attachment.
* Update promoting notice.
* Improve coding standards.

= 2.4.4 - 2021/05/24 =
* Fix truncate option when used along with post title conversion.
* Change deploy script.

= 2.4.3 - 2021/03/15 =
* Fix truncate option by removing max limit.
* Tested up to: 5.7.

= 2.4.2 - 2021/02/25 =
* Add "Accents conversion method" option.
* Add `transliterator_transliterate` function as an option to convert characters.

= 2.4.1 - 2021/02/21 =
* Tested up to: 5.6.
* Add Gutenberg title fix option.
* Fix composer autoload call.
* Update readme.

= 2.4.0 - 2020/12/07 =
* Prevent dots from extension being converted to dash in "Rules > Filename > Convert".
* Add `new_extension` parameter on `frou_sanitize_file_name` hook.
* Add multiselect field on admin.
* Tested up to: 5.5.
* Add log to ignored file extensions.

= 2.3.9 - 2020/06/18 =
* Disable renaming when using WooCommerce Export Products.
* Create 'frou_renaming_validation' filter.
* Fix blocking by extension.
* Fix wrong string
* Improve datetime option
* Tested up to: 5.4

= 2.3.8 - 2019/11/26 =
* Fix posttitle rule removing spaces from titles

= 2.3.7 - 2019/11/17 =
* Fix 'posttitle' rule when title is formed with non latin characters.

= 2.3.6 - 2019/11/15 =
* Fix 'posttitle' rule after WordPress 5.3

= 2.3.5 - 2019/11/13 =
* Fix 'Parameter must be an array or an object that implements Countable'
* Tested up to: 5.3

= 2.3.4 - 2019/04/12 =
* Fix warning on 'upgrader_process_complete' hook where $options['plugins'] are not always present

= 2.3.3 - 2019/04/11 =
* Tested up to: 5.1

= 2.3.2 - 2019/02/10 =
* Improve Ignored Messages field
* Add sounds section on settings
* Improve premium notices on admin
* Add default ignored messages preventing empty popups
* Improve readme

= 2.3.1 - 2019/01/23 =
* Add filter 'frou_filename_allowed'
* Tested up to: 5.0

= 2.3.0 - 2018/11/02 =
* Add more names to ignore filenames option regarding visual composer
* Add 'frou_after_sanitize_file_name' filter
* Add option to not rename files without extension trying to prevent third party compatibility

= 2.2.9 - 2018/07/27 =
* Check if rules exist before convert filename
* Add more names to ignore filenames option regarding visual composer

= 2.2.8 - 2018/04/20 =
* Check if permalink option is enabled on add_attachment function

= 2.2.7 - 2018/03/30 =
* Make it compatible with Nextgen gallery plugin

= 2.2.6 - 2018/03/26 =
* Update translation file
* Add persian translation
* Config auto deploy with travis
* Add wp.org assets on github

= 2.2.5 - 2018/01/30 =
* Fix empty function

= 2.2.4 - 2018/01/26 =
* Add translation to some missing strings
* Add option to truncate filename

= 2.2.3 - 2017/11/27 =
* Fix notice checking
* Replace "install_plugins" permission by "edit_users"
* Tested up to WordPress 4.9

= 2.2.2 =
* Update pot file
* Add strings to translation

= 2.2.1 =
* Set transient on update

= 2.2.0 =
* Open tab if hash is present
* Improve settings api
* Create notice asking for review
* Create notice talking about the pro version
* Improve plugin's description

= 2.1.9 =
* Create a filter to get the parent post id (frou_parent_post_id)

= 2.1.8 =
* Create a filter to ignore filename extensions (frou_ignored_extensions)

= 2.1.7 =
* Improve function to get post title, even with unsaved posts

= 2.1.6 =
* Add new filter 'frou_admin_sections' to filter admin sections
* Improve settings api
* Update tested up to
* Restrict settings to administrators only

= 2.1.5 =
* Add new option to convert characters to dash

= 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

== Upgrade Notice ==

= 1.0 =
* Initial release