Prevent resizing of images when resize mode is proportional and width and height of the image equal
devkev16 opened this issue · 2 comments
The ResizeConfiguration has a method where it checks whether an resize is unnecessary. Theres a missing check whether the height and width on the image are already equal when the resize mode is "proportional".
One good reason to change this behavior is: The image URLs don't change during an upgrade from an older version, this could be bad in perspective of seo (google images rankings).
This function:
image/src/ResizeConfiguration.php
Lines 41 to 47 in 1846080
Would need to check it like this:
/**
* Returns true if the resize would have no effect.
*/
public function isEmpty(): bool
{
$size_and_mode_proportional = ($this->width === $this->height) && ($this->mode === self::MODE_PROPORTIONAL);
return (0 === $this->width
&& 0 === $this->height
&& 0 === $this->zoomLevel)
|| $size_and_mode_proportional;
}
I think I don’t fully understand that.
Resizing images for example to 100 by 100 in mode proportional
would mean that landscape images get resized to 100 pixel width and portrait images to 100 pixel height. isEmpty()
must not return true in this case because an actual resize of the image is necessary.
Can you give an example of how your code that does the resize looks like?