You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Image mime type is not set correctly when a webp image is generated. #67
@mitogh Similar to #69, this may be because the source image is still JPEG if it was originally JPEG. Try uploading a WebP image directly, in that case it should say image/webp. cc @adamsilverstein
The mime type in the media library should show the mime type of the image you uploaded - the original image, not the mime type of the sub sizes (of which there could be potentially more than one) which is what the webp-uploads module changes. So if your original image is a jpeg, this should show image/jpeg (even if your sub-sized images are WebP). Similarly, if you upload a WebP image, this should show image/webp
@mitogh Similar to #69, this may be because the source image is still JPEG if it was originally JPEG. Try uploading a WebP image directly, in that case it should say image/webp. cc @adamsilverstein
Uploading a WebP image correctly sets the correct mime type @felixarntz
The mime type in the media library should show the mime type of the image you uploaded - the original image, not the mime type of the sub sizes (of which there could be potentially more than one) which is what the webp-uploads module changes. So if your original image is a jpeg, this should show image/jpeg (even if your sub-sized images are WebP). Similarly, if you upload a WebP image, this should show image/webp
Agree with this behavior, however, the behavior is not consistent when a scaled version is created which would be created as a WebP if the module is enabled. I'm adding more details below, so we can make a decision. @adamsilverstein in how to move forward when this scenario is presented.
Questions / Needs decision
Full image should be converted to WebP (including scaled version)?
Should scaled version be converted to WebP?
If full image is converted to WebP should the original JPEG be stored in original_image similar to WordPress behavior?
Should the mime type on the post ( post_mime_type property ) match the full image or the uploaded image?
When a large (in dimensions) image is uploaded to WordPress (see Image 1 at the bottom), WordPress would create a subsize with the suffix scaled, this image would be converted to WebP giving inconsistent behavior in the UI when this is the case.
Discrepancy between URL from full image size and mime type in the admin
The Full URL from the editor would be https://galaxy.lndo.site/wp-content/uploads/2022/01/zhan-zhang-lfAW14Oxh14-unsplash-scaled.webp while the modal displays an image/jpeg mime type.
This behavior is correctly displayed on the single view of the media, where both displays the correct mime type WebP for the URL and the UI.
The original image (very large image in JPEG format) is uploaded as well and stored in the same directory as the scaled version, the current behavior from WordPress is this and the path to this image is stored in original_image key of the image meta. See the next section with the sample data of the image.
This is the current behavior in WordPress with the difference when the module is enabled t
When a smaller image is uploaded the scaled version is not created and the UI does not present inconsistencies (Use Image 2 to replicate this scenario) however the mime type is always JPEG.
URL of the image https://galaxy.lndo.site/wp-content/uploads/2022/01/leon-s-y4TzCAsLego-unsplash-1.jpg from the modal UI.
As described above the module for WebP works as expected but I'm not 100% if the current behavior is intended due to this behavior being inconsistent when different image sizes are uploaded, the main idea/question is to define the path we want to implement for the full image size based on that decision most of the initial questions would be answered.
@mitogh I have created a PR that skips the scaled image transformation - #143 can you give that a test, it should fix this issue at least for the single mime output use case.
Activity
felixarntz commentedon Dec 22, 2021
@mitogh Similar to #69, this may be because the source image is still JPEG if it was originally JPEG. Try uploading a WebP image directly, in that case it should say
image/webp. cc @adamsilversteinadamsilverstein commentedon Jan 31, 2022
The mime type in the media library should show the mime type of the image you uploaded - the original image, not the mime type of the sub sizes (of which there could be potentially more than one) which is what the webp-uploads module changes. So if your original image is a jpeg, this should show
image/jpeg(even if your sub-sized images are WebP). Similarly, if you upload a WebP image, this should showimage/webpmitogh commentedon Jan 31, 2022
Uploading a
WebPimage correctly sets the correct mime type @felixarntzAgree with this behavior, however, the behavior is not consistent when a
scaledversion is created which would be created as a WebP if the module is enabled. I'm adding more details below, so we can make a decision. @adamsilverstein in how to move forward when this scenario is presented.Questions / Needs decision
scaledversion be converted to WebP?fullimage is converted to WebP should the original JPEG be stored inoriginal_imagesimilar to WordPress behavior?post_mime_typeproperty ) match thefullimage or the uploaded image?This is closely related to #96 (comment)
Description
Scenario 1 - Very large image
When a large (in dimensions) image is uploaded to WordPress (see Image 1 at the bottom), WordPress would create a subsize with the suffix
scaled, this image would be converted to WebP giving inconsistent behavior in the UI when this is the case.Discrepancy between URL from full image size and mime type in the admin
The Full URL from the editor would be
https://galaxy.lndo.site/wp-content/uploads/2022/01/zhan-zhang-lfAW14Oxh14-unsplash-scaled.webpwhile the modal displays animage/jpegmime type.This behavior is correctly displayed on the single view of the media, where both displays the correct mime type WebP for the URL and the UI.
The original image (very large image in JPEG format) is uploaded as well and stored in the same directory as the
scaledversion, the current behavior from WordPress is this and the path to this image is stored inoriginal_imagekey of the image meta. See the next section with the sample data of the image.This is the current behavior in WordPress with the difference when the module is enabled t
Meta information of the image
See:
WebP#69webpimage is generated. #67Scenario 2 - Small image
When a smaller image is uploaded the
scaledversion is not created and the UI does not present inconsistencies (Use Image 2 to replicate this scenario) however the mime type is always JPEG.URL of the image
https://galaxy.lndo.site/wp-content/uploads/2022/01/leon-s-y4TzCAsLego-unsplash-1.jpgfrom the modal UI.Metadata of the image
Inconsistencies
As described above the module for WebP works as expected but I'm not 100% if the current behavior is intended due to this behavior being inconsistent when different image sizes are uploaded, the main idea/question is to define the path we want to implement for the
fullimage size based on that decision most of the initial questions would be answered.Resources
Image 1
Image 2
adamsilverstein commentedon Feb 1, 2022
@mitogh I have created a PR that skips the scaled image transformation - #143 can you give that a test, it should fix this issue at least for the single mime output use case.
mitogh commentedon Feb 1, 2022
Just tested this fix and works as expected @adamsilverstein 👍