[wp-trac] [WordPress Trac] #48974: -1 being added to image uploads with Version 5.3.1

WordPress Trac noreply at wordpress.org
Sat Dec 14 20:10:43 UTC 2019


#48974: -1 being added to image uploads with Version 5.3.1
-------------------------------+------------------------------
 Reporter:  neotrope           |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  General            |     Version:  5.3.1
 Severity:  normal             |  Resolution:
 Keywords:  needs-patch close  |     Focuses:
-------------------------------+------------------------------
Changes (by pbiron):

 * keywords:  needs-patch => needs-patch close


Comment:

 Hi @neotrope, welcome to WordPress Trac.

 That behavior is indeed new in WP 5.3.1.

 You can read more about the reasons behind the change at #42437.

 The short explanation is as follows:

 1. WP has long automatically added -1, -2, -3, etc when you upload a file
 with the same name multiple times (e.g., suppose you uploaded `my-
 image.jpg` yesterday, when you upload another file named `my-image.jpg`
 tomorrow, WP renames the new file to `my-image-1.jpg`).  It does this for
 **any** file type, not just images.
 2. when WP creates the various "sub-sizes" of image files, it has long
 added the dimensions of the sub-size to the filename, e.g., when creating
 the default "thumbnail" filesize for `my-image.jpg`, WP creates `my-image-
 150x150.jpg`.
 3. however, because of number 2, prior to the change in WP 5.3.1, if after
 uploading `my-image.jpg`, you then uploaded `my-image-150x150.jpg` that
 would overwrite the previously created "thumbnail" for `my-image.jpg`.
 Similarly, if you first uploaded `my-image-150x150.jpg` and then later
 uploaded `my-image.jpg` the "thumbnail" for `my-image.jpg` would overwrite
 the original image `my-image-150x150.jpg`.

 So, this change is to actually protect uploaded image files and WP-
 generated sub-size image files from overwriting each other.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48974#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list