Auto Image Upload Rename
Automatically clean uploaded image filenames by converting to lowercase, removing special characters, and adding a unique identifier. Turn “Screenshot 2024-03-15 at 9.23.45 AM.png” into “screenshot-2024-03-15-at-9-23-45-am-x7k.png”.
Use Cases
- Convert camera filenames like DSC_0001.jpg to readable, SEO-friendly names
- Clean up messy client uploads with spaces and special characters
- Ensure server compatibility by removing problematic characters
How It Works
This is a toggle module — enable it and all future image uploads are automatically renamed. No configuration needed.
When an image is uploaded:
- Filename converted to lowercase
- Spaces and special characters replaced with hyphens
- Multiple hyphens collapsed to single hyphens
- 3-character unique ID appended to prevent collisions
- Clean filename used for the upload
Examples
| Original Filename | After Rename |
|---|---|
DSC_0001.jpg | dsc-0001-x7k.jpg |
Screenshot 2024-03-15 at 9.23.45 AM.png | screenshot-2024-03-15-at-9-23-45-am-f2p.png |
HÉRO Banner (Final).jpg | hero-banner-final-m9q.jpg |
Product Photo #1.png | product-photo-1-k3r.png |
...weird...file...jpg | weird-file-a5t.jpg |
What Gets Cleaned
| Character Type | Treatment |
|---|---|
| Uppercase letters | Converted to lowercase |
| Spaces | Replaced with hyphens |
Special characters (#$%&) | Replaced with hyphens |
Accented letters (é, ñ, ü) | Replaced with hyphens |
| Multiple hyphens | Collapsed to single hyphen |
| Leading/trailing hyphens | Removed |
Characters Preserved
These characters remain in filenames:
- Lowercase letters (a-z)
- Numbers (0-9)
- Hyphens (-)
- Underscores (_)
- Periods (.)
- @ symbol
The Unique ID
Every renamed file gets a 3-character unique identifier:
product-photo-x7k.jpg
^^^
Unique IDThis prevents filename collisions when uploading multiple files with similar names. Without it, uploading three “product.jpg” files would create “product.jpg”, “product-1.jpg”, “product-2.jpg”. With the ID, each gets a unique name from the start.
Length Limit
Filenames are limited to 50 characters (before extension) to prevent issues with long paths and certain servers.
Long filenames are truncated cleanly:
this-is-a-very-long-filename-that-exceeds-the-maximum-allowed-length.jpg
→ this-is-a-very-long-filename-that-exceeds-the-m-k2f.jpgWhy Clean Filenames Matter
SEO Benefits
Search engines use filenames as signals. red-running-shoes.jpg tells Google more than IMG_4521.jpg.
Server Compatibility
Some servers struggle with spaces, special characters, or non-ASCII characters in filenames. Clean names prevent 404 errors and broken images.
Easier Management
Clean, consistent filenames are easier to find and manage when browsing files via FTP or file managers.
URL Readability
Image URLs become human-readable:
Bad: /uploads/Screenshot%202024-03-15%20at%209.23.45%20AM.png
Good: /uploads/screenshot-2024-03-15-at-9-23-45-am-f2p.pngWhat’s Not Changed
- File extension — .jpg stays .jpg
- File content — Only the name changes, not the image
- Existing files — Only new uploads are renamed
FAQ
Does this affect existing images?
No. Only new uploads are renamed. Your existing media library is unchanged.Can I disable this for specific uploads?
Not currently. The module applies to all image uploads while enabled. Disable the module temporarily if you need to preserve an exact filename.Why is there a random code at the end?
The 3-character ID prevents filename collisions. If you upload “photo.jpg” twice, instead of “photo.jpg” and “photo-1.jpg”, you get unique names like “photo-x7k.jpg” and “photo-m2p.jpg”.Does this work with all file types?
This module only renames images (JPEG, PNG, GIF, WebP, etc.). Documents, videos, and other files keep their original names.Will this break my links?
No. The renaming happens during upload, before any links are created. All WordPress references use the new clean filename.Can I customize the naming pattern?
Currently, the module uses a fixed cleaning pattern. Advanced customization would require code modifications.Get access to all 147 modules with a single license