• Resolved we-are-ferris

    (@weareferris)


    Hi all, can anyone tell me from what version WordPress started automatically renaming files ending in something like 500×500 (e.g. android-chrome-512×512.png becomes android-chrome-512×512-1.png). And no, there is no other file with the same name that has already been uploaded. This happens with all files, no matter what name they have, as soon as they have the dimension at the end of the name. I have not worked with WordPress for some time. With my last WP projects, around 2022/23, this was not yet the case.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 1) Those are the thumbnail versions created. By default, WordPress generates up to three of these thumbnail sizes, but themes and plugins can also register additional thumbnail sizes to be generated.

    2) The original file is always there with the exact file name you gave it. Just remove those extra characters (eg -512×512 in your example), and the remaining URL ending in android-chrome.png will open the original file.

    3) This has always been the case for as long as WordPress has generated thumbnail images. There’s nothing new here. (I don’t know when WordPress introduced thumbnail generation, but it should go back at least 15 years.)

    Thread Starter we-are-ferris

    (@weareferris)

    Thanks for your very fast reply ??

    Unfortunately, it has nothing to do with the thumbnail versions. To reproduce the described behavior, simply upload an image file with the name test-32×32.png (or any other image type) to your next fresh WordPress installation (no plugins, standard theme – twenty….) and then check the file name in the upload folder. This has been renamed to test-32×32-1.png . When I check the upload folder via FTP, there is now exactly 1 file there, namely test-32×32-1.png and not test-32×32.png as would actually be expected. With a size of 32×32 px, no thumbnail versions are created. And as I already mentioned, this was not the case with earlier WP versions.

    Screenshots:
    https://ibb.co/RHSNVSj
    https://ibb.co/p4WNnrp


    OK, sorry I misunderstood your question.

    I’ve been able to reproduce this in WordPress 6.5.5. I also rolled back several versions, and it seems 5.3 was the first to do this. And while I’ve not been able to dig out a trac ticket on the subject, I think this change was meant to deal with situations where thumbnails would overwrite similarly-named original files.

    Consider this scenario:

    — You upload a file test-300x300.png and WordPress uploads it as-is (pre 5.2). WordPress will append the appropriate dimensions to save the generated thumbnails… but the original file remains test-300x300.png

    — But what happens when you now upload a new file test.png. Assuming this file is large enough, the (default) “Medium” thumbnail is supposed to be test-300x300.png — but we have an original file with this name already!

    I just tested out this very scenario in a WordPress 5.2 instance… and, in my test, the original file was overwritten by the newly generated thumbnail!

    There’s no way to know in advance what themes and plugins users are going to install (hence what thumbnail dimensions are to be generated). Thus the new behaviour.

    Thread Starter we-are-ferris

    (@weareferris)

    Yes, of course that makes sense. I was thinking something like that too. Actually, my original problem was that favicons (and all those for Android, Apple + MS) are renamed. Of course, it would have been nice if a few exceptions had been made here. Favicon sizes are basically the different thumbnail sizes ?? and if they are named correctly according to the manufacturer, they always have the same name plus the dimension appended. So we have favicon-*, apple-touch-icon-*, android-chrome-* and mstile-*.

    However, since this is not a bug or anything, and for certain reasons I need the icon names without this appended “-1”, I have solved it with some rewrite rules in the htaccess.

    Many, many thanks for your help and the detailed information on the subject.

    • This reply was modified 5 months ago by we-are-ferris. Reason: Typos and forgot the threat as resolved (sorry guys)
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.