-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Bug Description
The current implementation to create images in additional mime types, the image uses the attached image, with get_attached_file
when the image is larger a scaled
version would be created, however, WordPress creates all the subsizes using the original image instead of the scaled
version.
The main problem with the current approach is that in some cases won't create an image of the exact size as the original image, one thing to mention is that the created image on the additional mime types would be of the same aspect ratio, usually, this happens when the scaled version is smaller in dimensions that the created image.
One of the major problems when using the original image is that the resulting WebP images would result bigger in size than the same version in a JPEG, at least specifically with this image and the default quality setting for WebP, this is mostly because the current approach creates a WebP version out of an already compressed version. So would be something to consider either adjust the default WebP from within the plugin to make sure the generated WebP files result in smaller versions of the same JPEG image.
Steps to reproduce
Given the following image subsizes:
> array(6) {
["thumbnail"]=>
array(3) {
["width"]=>
int(150)
["height"]=>
int(150)
["crop"]=>
bool(true)
}
["medium"]=>
array(3) {
["width"]=>
int(300)
["height"]=>
int(300)
["crop"]=>
bool(false)
}
["medium_large"]=>
array(3) {
["width"]=>
int(768)
["height"]=>
int(0)
["crop"]=>
bool(false)
}
["large"]=>
array(3) {
["width"]=>
int(1024)
["height"]=>
int(1024)
["crop"]=>
bool(false)
}
["1536x1536"]=>
array(3) {
["width"]=>
int(1536)
["height"]=>
int(1536)
["crop"]=>
bool(false)
}
["2048x2048"]=>
array(3) {
["width"]=>
int(2048)
["height"]=>
int(2048)
["crop"]=>
bool(false)
}
}
- Upload the following image
- Add the following filter on your site:
// Use a 1500 threshold
add_filter(
'big_image_size_threshold',
function () {
return 1500;
}
);
- And observe the metadata of the image and observe the size
1536x1536
the 2 images have different sizes:
Original JPEG image dimensions are: 1024x1536
Additional WebP dimensions are: 1000x1500
Screenshots
Additional Context
- PHP Version: 7
- OS: Linux 5.15.12-1-MANJARO x86_64
- Browser: Chrome
- Plugin Version:
release/1.0.0-beta.1
- Device: Desktop.