Skip to content

WebP file overwritten if filename has the same name with extension of jpeg and jpg #358

Description

@pixel-paul

Bug Description

This may be a misconfiguration issue, but at the moment if a file is uploaded with the same filename but the extension is jpeg or jpg, the corresponding webp file generated is overwritten by the last file uploaded.

Steps to reproduce

  1. Create 2 files, for example, Paul-Test.jpeg and Paul-Test.jpg
  2. Go to Media Gallery
  3. Click on Add New
  4. Upload Paul-Test.jpeg
  5. Check ~/wp-content/uploads/2022/06/Paul-Test.jpeg
  6. Check ~/wp-content/uploads/2022/06/Paul-Test.webp
  7. Upload Paul-Test.jpg
  8. Check ~/wp-content/uploads/2022/06/Paul-Test.jpg
  9. Check ~/wp-content/uploads/2022/06/Paul-Test.webp
  10. The file Paul-Test.webp created from Paul-Test.jpeg is overwritten with the webp generated from Paul-Test.jpg

Additional Context

I have added this to functions.php:

/* Image conversion attributes */
add_filter('webp_uploads_upload_image_mime_transforms', function () {

    return [
        'image/jpeg' =>  [ 'image/jpeg', 'image/webp' ],
        'image/png' =>  [ 'image/png', 'image/webp' ],
        'image/webp' =>  [ 'image/webp', 'image/jpeg' ],
    ];
});
  • PHP Version: 7.4
  • OS: RHEL 8.6
  • Browser: Firefox
  • Plugin Version: 1.1.0

To note, PNGs with the same filename do not overwrite the webp image (an image is not created at all).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions