Support » Plugin: EWWW Image Optimizer » Number added to the image filename

  • Resolved Samuel Aguilera



    I just found that when you run optimization with PNG to JPG conversion active (or when you force the conversion manually). The new file gets a number (usually ‘1’) in the filename.

    So if you optimize the file Image.png, you will end with a new file with the name Image1.jpg

    That’s not good 🙁 it brokes your “pretty” filenames that you put carefully adding that number.

    And it makes not sense, because if you do the optimize over a file on the same format, for example if you optimize a JPG file (not changing format), the filename remains exactly the same, no changes…

    I think (IMHO) that should be the default behaviour in all cases, keeping the filename without changes.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author nosilver4u


    That’s what I think too, but it wasn’t possible to avoid file-name collisions during conversion without appending a number every time.

    Well.. I can’t understand why. You don’t have that problem when optimizing JPG to same JPG file? That’s the same filename.

    It should not be a problem when optimizing PNG to JPG, because the name for the new file does not exists. The original file is .png the new one is .jpg totally different names.

    In fact, I make some testing and change line 1500 of ewww-image-optimizer.php to this:

    $jpgfile = $filename . $fileext;

    (Leaving $filenum intact in the rest of the process)

    And seems to work fine 😉

    Plugin Author nosilver4u


    Ok, you’re going to make me spell it out…

    It’s an extreme edge case, but here’s the problem:

    1. Check the option to delete originals on conversion (not the default).
    2. Upload someimage.gif and convert it to someimage.png
    3. Upload someimage.gif without converting
    4. Click the revert link for someimage.png, which renames it back to someimage.gif

    Now, you have two items in the media library sharing the same file. Best case, they actually were the same image, and it’s no big deal. If you delete one, it will leave an orphaned entry in media library though.

    Worst case, they actually were 2 different images with the same name, and you’ve just overwritten the second image with the first one. Bad.

    There’s probably some room for improvement there, but the file-naming stuff was enough of a headache when I implemented conversion, and I don’t want to delve back into that mess.

    Plugin Author nosilver4u


    Remembered there was a second reason for the existing behavior also. Because we’re dealing with all ‘resizes’ and not just the original image, we have to look out for those too. If we don’t append a number to them, wordpress will clobber the resizes if you ever upload a file with the same name.

    I have a file in my uploads directory – NBFHeader.png. But when I try to insert it as a site logo in the Magazino customizer accordion sitelogo section it adds a number to the file – NBFHeader1.png – and creates a new file in the Uploads directory. Then I get a broken link. Why is this happening? And if I then try to add that file it becomes NBFHeader2.png This is driving me crazy because it only happens on the Windows production server and not the Mac dev. Help Please

    Plugin Author nosilver4u



    1. Please don’t post on someone else’s thread.
    2. even if this was your own thread, that is not an issue related to this plugin, so I can’t help you. This plugin only renames images when you convert them to a different format.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Number added to the image filename’ is closed to new replies.