Skip to content

Commit

Permalink
Properly calculate height of transformed images
Browse files Browse the repository at this point in the history
Fixes an issue where the height of a non-cropped image being transformed was being calculated as a percentage of the height rather than of the width.

#11837

Fixes an issue where the height of a non-cropped image being transformed was being calculated as a percentage of the height rather than of the width.

#11837
  • Loading branch information
brianjhanson committed Aug 30, 2022
1 parent a01c8c6 commit d8391b1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixed
- Fixed an error that could occur when upgrading to Craft 4, if any Matrix blocks contained null `sortOrder` values. ([#11843](https://github.com/craftcms/cms/issues/11843))
- Fixed an issue where image dimensions could be calculated incorrectly when `upscaleImages` was false ([#11837](https://github.com/craftcms/cms/issues/11837))

## 4.2.3 - 2022-08-26

Expand Down
2 changes: 1 addition & 1 deletion src/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,7 @@ private function _dimensions(mixed $transform = null): array
return [$this->_width, $this->_height];
}

return $transformRatio > 1 ? [$this->_width, round($this->_height / $transformRatio)] : [round($this->_width * $transformRatio), $this->_height];
return $transformRatio > 1 ? [$this->_width, round($this->_width / $transformRatio)] : [round($this->_width * $transformRatio), $this->_height];
}

[$width, $height] = Image::calculateMissingDimension($transform->width, $transform->height, $this->_width, $this->_height);
Expand Down

0 comments on commit d8391b1

Please sign in to comment.