#63180 closed defect (bug) (invalid)
Media Library Incorrectly Identifies Non-Identical Filenames as Duplicates
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.7.2 |
Component: | Media | Keywords: | needs-patch |
Focuses: | Cc: |
Description
The WordPress Media Library's duplicate detection system incorrectly identifies files as duplicates when one filename is a substring of another, even though they are distinct files.
Steps to Reproduce:
- Upload an image named "101iw500501.jpg"
- Upload a different image named "500501.jpg"
- Observe that WordPress treats the second file as a duplicate of the first, appending a suffix (e.g., "-1")
This does not apply the other way around. If the image "500501.jpg" is uploaded first, the second image, "101iw500501.jpg," will be treated as a distinct, new image.
I noticed the issue the first time using the API to upload images and verified it using the WP backend and Media Manager.
Expected Behavior:
- WordPress should only consider files as duplicates if their filenames are identical
- "101iw500501.jpg" and "500501.jpg" should be treated as distinct files, as they represent different product SKUs
Impact:
In our case, we sync products from an external ERP into WooCommerce and keep data in sync. Therefore, if the second image is treated as a duplicate and stored with a suffix (-1, -2, etc.), it will not be recognized as an existing, matching image in the next sync run and will be continuously uploaded again with a new suffix.
Use Case Example:
In our WooCommerce integration:
- ERP sends image file names like "101iw500501.jpg"
- The corresponding image is named "101iw500501.jpg"
- Another product is sent with the image file "500501.jpg"
- WordPress renames it to "500501-1.jpg" because "101iw500501.jpg" exists
- The synchronization system fails to match the existing image in WordPress with the one sent from the ERP
- This requires manual intervention to correct the image-product association
Environment:
- WordPress Version: 6.7.2
- PHP Version: 8.1.31
Attachments (3)
Change History (6)
@
7 weeks ago
screenshot of media library where the file renaming suggested by this ticket doesn't happen
#1
@
7 weeks ago
- Keywords reporter-feedback added
Hi @zahnd
Thanx for the report (and welcome to Trac)!
However, I'm not able to reproduce the situation of "500501.jpg" getting a "-1" appended to the filename.
I could be wrong, but I suspect you've got a plugin (or theme) that is hooking into the wp_unique_filename filter.
Have you tried with ALL plugins deactivated and a default theme (e.g., TT4)?
#2
@
7 weeks ago
- Resolution set to invalid
- Status changed from new to closed
Hi @pbiron
Thanks for your fast reply. You're completely right. Not an issue in WordPress. Sorry. The plugin causing the issue is "Image Regenerate & Select Crop". I'm going to notify them now.
Thanks and best regards, Stefan
not-working order of image upload