Opened 12 years ago
Closed 9 years ago
#21453 closed enhancement (fixed)
Appending hyphen before numbers when creating a create unique filename in wp_unique_filename()
Reported by: | husobj | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 2.5 |
Component: | Upload | Keywords: | has-patch |
Focuses: | Cc: |
Description
When WordPress appends a number to a file to create a unique filename, it just adds a number to the file.
ie If "photo.jpg" exists then "photo1.jpg" is created
I suggest that it should include a hyphen so the file would be called "photo-1.jpg"
The main reason is that if you upload files ending in numbers then then the new filename is less easy to read.
ie If "photo234.jpg" exists then "photo2341.jpg" is created
Would be nicer if it produced "photo234-1.jpg"
It's only cosmetic but it does make it easier to search for images in the uploads folder if you need to for any reason, especially if you have uploaded a load of images from a camera DSC123.jpg, DSC124.jpg etc
Attachments (2)
Change History (9)
#2
@
11 years ago
I've attached a patch for this. It will ensure appended numbers are prepended with a hyphen.
Works with both the extension case logic, when extension is non existent, and regular filenames.
#4
@
11 years ago
- Component changed from Filesystem to Upload
- Keywords 3.9-early added
- Milestone changed from Awaiting Review to Future Release
- Version set to 2.5
#5
@
9 years ago
- Keywords needs-unit-tests added; 3.9-early needs-testing removed
- Milestone changed from Future Release to 4.4
@
9 years ago
Altering Tests_Functions::test_wp_unique_filename()
to support the hyphen prefix when creating unique filenames
+1 for consistency with
wp_unique_post_slug()
andwp_uniquie_term_slug()