[wp-trac] [WordPress Trac] #49314: WordPress Adding "-1" to Uploaded Images

WordPress Trac noreply at wordpress.org
Tue Jan 28 18:23:04 UTC 2020


#49314: WordPress Adding "-1" to Uploaded Images
--------------------------+------------------------
 Reporter:  WebmasterT    |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Media         |     Version:  5.3.2
 Severity:  normal        |  Resolution:  duplicate
 Keywords:                |     Focuses:
--------------------------+------------------------
Changes (by SergeyBiryukov):

 * status:  new => closed
 * resolution:   => duplicate
 * milestone:  Awaiting Review =>


Old description:

> This problem occurs even when I deactivate all plugins and use the
> default theme.
>
> It began on December 13, 2019.
>

> When adding an image into the WordPress data that is labeled:
>
> this-picture-upload-01-700x400
>
> Wordpress has begun adding a -1 after the file name, creating:
>
> this-picture-upload-01-700x400-1
>
> This "-1" is typically added only when the exact same file name already
> exists in in the database.
>
> Now WordPress is adding it to any upload like this:
>
> this-picture-upload-01-700x400
>
> If I add a picture with a file name like this  (I actually added this
> into the database for you to see):
>
> drfdffdfsddfdfdfdf38
>
> Wordpress doesn't add "-1"
>
> But when I change that same file to this file name  (I actually added
> this into the database for you to see):
>
> qorianka-kilcher-the-new-world-01-1896x812
>
> Wordpress does this to the file name:
>
> qorianka-kilcher-the-new-world-01-1896x812-1
>
> Again, no other previous upload for "qorianka-kilcher-the-new-
> world-01-1896x812' exists in our system.
>
> ........
>
> I showed this problem to my website host, and this was their reply:
>
> I have set up a brand new fresh installation of Wordpress on my personal
> account.   There are no plugins or themes.   The installation was
> performed specifically to test this on a fresh install.
>
> =================
> [0159][root at sip1-228 /home/ehegelne/wp.ehegel.net/html]$ find . |grep -i
> jelly
> ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-300x225.jpg
> ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-150x150.jpg
> ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1.jpg
> ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-768x576.jpg
> =================
>

> =================
> [0200][root at sip1-228 /home/ehegelne/wp.ehegel.net/html]$ find . |grep -i
> koala
> ./wp-content/uploads/2020/01/Koala.jpg
> ./wp-content/uploads/2020/01/Koala-150x150.jpg
> ./wp-content/uploads/2020/01/Koala-768x576.jpg
> ./wp-content/uploads/2020/01/Koala-300x225.jpg
> =================
>
> As you can see the same behavior occurs.    I am not sure why Wordpress
> does this,  but it is default behavior of the application.
>
> .................
>

> Can this error be fixed please so that when a person adds a non-duplicate
> file like this-picture-upload-01-700x400, a "-1" is not added to it?
>
> Thank you.

New description:

 This problem occurs even when I deactivate all plugins and use the default
 theme.

 It began on December 13, 2019.


 When adding an image into the WordPress data that is labeled:

 this-picture-upload-01-700x400

 Wordpress has begun adding a -1 after the file name, creating:

 this-picture-upload-01-700x400-1

 This "-1" is typically added only when the exact same file name already
 exists in in the database.

 Now WordPress is adding it to any upload like this:

 this-picture-upload-01-700x400

 If I add a picture with a file name like this  (I actually added this into
 the database for you to see):

 drfdffdfsddfdfdfdf38

 Wordpress doesn't add "-1"

 But when I change that same file to this file name  (I actually added this
 into the database for you to see):

 qorianka-kilcher-the-new-world-01-1896x812

 Wordpress does this to the file name:

 qorianka-kilcher-the-new-world-01-1896x812-1

 Again, no other previous upload for "qorianka-kilcher-the-new-
 world-01-1896x812' exists in our system.

 ........

 I showed this problem to my website host, and this was their reply:

 I have set up a brand new fresh installation of WordPress on my personal
 account.   There are no plugins or themes.   The installation was
 performed specifically to test this on a fresh install.

 =================
 [0159][root at sip1-228 /home/ehegelne/wp.ehegel.net/html]$ find . |grep -i
 jelly
 ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-300x225.jpg
 ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-150x150.jpg
 ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1.jpg
 ./wp-content/uploads/2020/01/Jellyfish-01-2020-1024x768-1-768x576.jpg
 =================


 =================
 [0200][root at sip1-228 /home/ehegelne/wp.ehegel.net/html]$ find . |grep -i
 koala
 ./wp-content/uploads/2020/01/Koala.jpg
 ./wp-content/uploads/2020/01/Koala-150x150.jpg
 ./wp-content/uploads/2020/01/Koala-768x576.jpg
 ./wp-content/uploads/2020/01/Koala-300x225.jpg
 =================

 As you can see the same behavior occurs.    I am not sure why Wordpress
 does this,  but it is default behavior of the application.

 .................


 Can this error be fixed please so that when a person adds a non-duplicate
 file like this-picture-upload-01-700x400, a "-1" is not added to it?

 Thank you.

--

Comment:

 Hi there, welcome to WordPress Trac! Thanks for the ticket.

 That behavior is indeed new in WP 5.3.1, introduced in [46822] / #42437.

 You can read more about the reasons behind the change in tickets #48974
 and #42437, specifically these comments:

 * comment:2:ticket:48974 has a good explanation.
 * comment:8:ticket:48974 suggests a way to override it.

 Hope this helps. Since it's the same issue as reported in #48974, the
 discussion can continue there if necessary.

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


More information about the wp-trac mailing list