Skip to content

Commit 1fd35b1

Browse files
committed
raw parameter support
1 parent 715a05b commit 1fd35b1

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ https://ik.imagekit.io/your_imagekit_id/endpoint/default-image.jpg?tr=f-jpg%2Cpr
191191

192192
The complete list of transformations supported and their usage in ImageKit can be found [here](https://docs.imagekit.io/features/image-transformations). The SDK gives a name to each transformation parameter, making the code simpler and readable. If a transformation is supported in ImageKit, but a name for it cannot be found in the table below, then use the transformation code from ImageKit docs as the name when using in the `url` function.
193193

194+
If you want to generate transformations in your application and add them to the URL as it is, use the `raw` parameter.
195+
194196
| Supported Transformation Name | Translates to parameter |
195197
|-------------------------------|-------------------------|
196198
| height | h |
@@ -249,6 +251,7 @@ The complete list of transformations supported and their usage in ImageKit can b
249251
| effectContrast | e-contrast |
250252
| effectGray | e-grayscale |
251253
| original | orig |
254+
| raw | The string provided in raw will be added in the URL as it is. |
252255

253256

254257
### File Upload

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imagekit-javascript",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Javascript SDK for using ImageKit.io in the browser",
55
"main": "dist/imagekit.cjs.js",
66
"module": "dist/imagekit.esm.js",

src/url/builder.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export const buildURL = (opts: UrlOptions & ImageKitOptions) => {
3737
} else {
3838
urlObj = new URL(opts.src!);
3939
isSrcParameterUsedForURL = true;
40-
}
41-
} catch(e) {
40+
}
41+
} catch (e) {
4242
console.error(e)
4343
return "";
4444
}
@@ -89,6 +89,8 @@ function constructTransformationString(transformation: Transformation[] | undefi
8989

9090
if (transformation[i][key] === "-") {
9191
parsedTransformStep.push(transformKey);
92+
} else if (key === "raw") {
93+
parsedTransformStep.push(transformation[i][key]);
9294
} else {
9395
var value = transformation[i][key];
9496
if (transformKey === "oi" || transformKey === "di") {

test/url-generation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,11 @@ describe("URL generation", function () {
337337
effectContrast: true,
338338
effectGray: true,
339339
original: true,
340+
raw: "this_should_come_as_it_is"
340341
}]
341342
})
342343

343-
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two%20words,ots-20,otf-Open%20Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,orig-true/test_path.jpg?ik-sdk-version=javascript-${pkg.version}`);
344+
expect(url).equal(`https://ik.imagekit.io/test_url_endpoint/tr:h-300,w-400,ar-4-3,q-40,c-force,cm-extract,fo-left,f-jpeg,r-50,bg-A94D34,b-5-A94D34,rt-90,bl-10,n-some_name,ox-35,oy-35,ofo-bottom,oh-20,ow-20,oi-folder@@file.jpg,oit-false,oiar-4:3,oibg-0F0F0F,oib-10_0F0F0F,oidpr-2,oiq-50,oic-force,ot-two%20words,ots-20,otf-Open%20Sans,otc-00FFFF,oa-5,ott-b,obg-00AAFF55,ote-b3ZlcmxheSBtYWRlIGVhc3k%3D,otw-50,otbg-00AAFF55,otp-40,otia-left,or-10,pr-true,lo-true,t-5,md-true,cp-true,di-folder@@file.jpg,dpr-3,e-sharpen-10,e-usm-2-2-0.8-0.024,e-contrast-true,e-grayscale-true,orig-true,this_should_come_as_it_is/test_path.jpg?ik-sdk-version=javascript-${pkg.version}`);
344345
});
345346
});
346347

0 commit comments

Comments
 (0)