diff --git a/package.json b/package.json index d1395ac3..92c15a1f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "author": "Frederick Fogerty (https://github.com/frederickfogerty)", "contributors": [ "Frederick Fogerty (https://github.com/frederickfogerty)", - "Max Kolyanov (https://github.com/maxkolyanov)" + "Max Kolyanov (https://github.com/maxkolyanov)", + "Sherwin Heydarbeygi (https://github.com/sherwinski)" ], "license": "ISC", "bugs": { diff --git a/src/react-imgix-bg.jsx b/src/react-imgix-bg.jsx index c86cfe18..3472c1a8 100644 --- a/src/react-imgix-bg.jsx +++ b/src/react-imgix-bg.jsx @@ -84,11 +84,11 @@ const BackgroundImpl = props => { const renderedSrc = (() => { const srcOptions = { + fit: "crop", ...imgixParams, ...(disableLibraryParam ? {} : { ixlib: `react-${PACKAGE_VERSION}` }), width, height, - fit: "crop", dpr }; diff --git a/test/integration/react-imgix.test.jsx b/test/integration/react-imgix.test.jsx index b63babcf..38d17713 100644 --- a/test/integration/react-imgix.test.jsx +++ b/test/integration/react-imgix.test.jsx @@ -559,6 +559,30 @@ describe("Background Mode", () => { expect(ref instanceof HTMLElement).toBe(true); expect(findURIfromSUT(sut).getQueryParamValue("w")).toBe("100"); }); + it("the fit parameter defaults to 'crop'", async () => { + const sut = await renderBGAndWaitUntilLoaded( +
+ +
Content
+
+
+ ); + + const bgImageSrcURL = findURIfromSUT(sut); + expect(bgImageSrcURL.getQueryParamValue("fit")).toBe("crop"); + }); + it("the fit parameter can be overriden", async () => { + const sut = await renderBGAndWaitUntilLoaded( +
+ +
Content
+
+
+ ); + + const bgImageSrcURL = findURIfromSUT(sut); + expect(bgImageSrcURL.getQueryParamValue("fit")).toBe("clip"); + }); }); function injectScript(src) {