When using the Image Optimizer, you may see the error: File with this name already exists.
This usually happens when WordPress shows different display names, but the actual file name on the server hasn’t changed.
The Cause
WordPress lets you change the media title in the Media Library — but this does not rename the underlying file.
If a user uploads the same image file multiple times, even with different display names, they may still have identical file names.
Example
Alex uploads an image with the file name myphoto.jpg and gives it the display name My Garden in the Media Library. They then edit the image and upload it again, giving it the display name My Garden in Winter. However, the actual file name remains myphoto.jpg.
The Image Optimizer checks files based on the actual file name, not the display name.
If it finds duplicates, it cannot optimize them and displays this error.
What You’ll See
- “File with this name already exists”
- Images not being compressed
- Optimization batch stopping or skipping files
The Solution
Option 1: Rename the Actual File
- Use a file manager or a file renaming plugin) to rename the file itself — for example:
- myphoto.jpg to myphoto1.jpg
- Refresh the Media Library.
Option 2: Re-upload the File With a New File Name
- Download the image.
- Rename the image — for example:
- myphoto.jpg to myphoto1.jpg
- Upload the image again with the new file name. and upload it again, but change the actual filename before uploading.
Once the filenames are unique, the Image Optimizer will process them correctly.
Summary
The error appears because the plugin optimizes files based on the real file name, and duplicates cannot be processed. Renaming the actual file or re-uploading it with a new filename will resolve the issue.