Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern Image Formats: Sub-sizes image didn't add original image extension #1560

Open
mukeshpanchal27 opened this issue Sep 24, 2024 · 6 comments
Assignees
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken

Comments

@mukeshpanchal27
Copy link
Member

Bug Description

While i test something i found that the uploaded image didn't add original image extension( -jpeg ) in the sub-sizes but it added in full size image.

<img 
    fetchpriority="high" 
    decoding="async" 
    width="1024" 
    height="576" 
    src="http://localhost:8888/wp-content/uploads/2024/09/car-1024x576.avif" 
    alt="" 
    class="wp-image-57" 
    srcset=
    "
        http://localhost:8888/wp-content/uploads/2024/09/car-1024x576.avif 1024w, 
        http://localhost:8888/wp-content/uploads/2024/09/car-300x169.avif 300w, 
        http://localhost:8888/wp-content/uploads/2024/09/car-768x432.avif 768w, 
        http://localhost:8888/wp-content/uploads/2024/09/car-jpeg.avif 1080w
    "
    sizes="(max-width: 1024px) 100vw, 1024px"
>

The issue happen for both(WebP/AVIF) mime type.

Steps to reproduce

  1. Install and activate Modern Image Formats plugin.
  2. Upload JPEG image
  3. See frontend.

Screenshots

Screenshot 2024-09-24 at 12 10 04 PM
@mukeshpanchal27 mukeshpanchal27 added [Type] Bug An existing feature is broken [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Sep 24, 2024
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Sep 24, 2024
@mukeshpanchal27
Copy link
Member Author

Seems like WP return additional mime images in meta instead JPEG that's why the image extension is not apply because the addition mime image is already present in meta data. See https://github.com/WordPress/performance/blob/trunk/plugins/webp-uploads/hooks.php#L214-L217

@joemcgill
Copy link
Member

Good catch, @mukeshpanchal27. While the lack of -jpeg in the filename is inconsistent between the full size and subsizes, I don't think this should have any side effects for that would impact user behavior.

@adamsilverstein can you confirm the expected behavior here? When we're replacing sub-sizes with a modern image format, do we expect the sub-sizes to contain the original file's mime in the new filename?

@mukeshpanchal27
Copy link
Member Author

JFYI In #444 we Add the original image's extension to the WebP file name to ensure it is unique.

@adamsilverstein
Copy link
Member

I will review and test.

We add the prefix to avoid naming collisions where two uploads foo.jpeg and foo.jpg (both valid) both get transformed into foo-200x200.webp, with the second upload overwriting the first. The actual file names are an implementation detail and are stored in the database, the important functional pieces here are that there are no file overwrites and that all files are deleted when the media is deleted in the media library.

@tehjaymo
Copy link

tehjaymo commented Oct 8, 2024

I think this is related to my issue here: #1499

@mukeshpanchal27
Copy link
Member Author

Thanks. Assigning to @adamsilverstein for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

4 participants