diff --git a/README.md b/README.md index 87a98407..a4c4a04a 100644 --- a/README.md +++ b/README.md @@ -76,11 +76,11 @@ This will generate HTML similar to the following: ```html @@ -100,8 +100,6 @@ import Imgix from "react-imgix"; />; ``` -NB: Since this library sets [`fit`](https://docs.imgix.com/apis/url/size/fit) to `crop` by default, when just a width or height is set, the image will resize and maintain aspect ratio. When both are set, the image will be cropped to that size, maintaining pixel aspect ratio (i.e. edges are clipped in order to not stretch the photo). If this isn't desired, set `fit` to be another value (e.g. `clip`) - [![Edit xp0348lv0z](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/charming-keller-kjnsq) #### Server-side rendering diff --git a/src/react-imgix.jsx b/src/react-imgix.jsx index 65393660..91f3a7f5 100644 --- a/src/react-imgix.jsx +++ b/src/react-imgix.jsx @@ -17,8 +17,7 @@ const NODE_ENV = process.env.NODE_ENV; const buildKey = idx => `react-imgix-${idx}`; const defaultImgixParams = { - auto: ["format"], - fit: "crop" + auto: ["format"] }; const defaultAttributeMap = { @@ -170,12 +169,7 @@ function buildSrc({ */ function imgixParams(props) { const params = Object.assign({}, defaultImgixParams, props.imgixParams); - - let fit = false; - if (params.crop != null) fit = "crop"; - if (params.fit) fit = params.fit; - - return Object.assign({}, params, { fit }); + return Object.assign({}, params); } /** diff --git a/test/unit/react-imgix.test.jsx b/test/unit/react-imgix.test.jsx index 13ed151a..8a400d91 100644 --- a/test/unit/react-imgix.test.jsx +++ b/test/unit/react-imgix.test.jsx @@ -456,16 +456,8 @@ describe("When using the component", () => { it("the rendered element should contain the class name provided", () => { expect(sut.props().className).toContain(className); }); - it("the crop param should alter the crop and fit query parameters correctly", () => { - sut = shallow( - - ); - - expectSrcsToContain(sut, "crop=faces%2Centropy"); - expectSrcsToContain(sut, "fit=crop"); - }); it("the fit param should alter the fit query pararmeter correctly", () => { - expectSrcsToContain(sut, "fit=crop"); + expectSrcsTo(sut, expect.not.stringContaining("fit=crop")); }); it("the keys of custom url parameters should be url encoded", () => { const helloWorldKey = "hello world";