Skip to content

Commit

Permalink
gpui: fix zed-industries#9931 img object-fit regression (zed-industri…
Browse files Browse the repository at this point in the history
…es#10006)

PR: zed-industries#9931 broke image scaling, such that it ignores the object-fit
parameter and instead always scales the image to fit the bounds. This
fixes the regression.
  • Loading branch information
MatthiasGrandl authored Mar 31, 2024
1 parent 3c8b376 commit b1ccead
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/gpui/src/elements/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ impl Element for Img {
let corner_radii = style.corner_radii.to_pixels(bounds.size, cx.rem_size());

if let Some(data) = source.data(cx) {
cx.paint_image(bounds, corner_radii, data.clone(), self.grayscale)
let new_bounds = self.object_fit.get_bounds(bounds, data.size());
cx.paint_image(new_bounds, corner_radii, data.clone(), self.grayscale)
.log_err();
}

Expand Down

0 comments on commit b1ccead

Please sign in to comment.