Skip to content

Commit cd911a8

Browse files
committed
fix(common): invalid ImageKit quality parameter
The current quality parameter is ignored by ImageKit.
1 parent f577319 commit cd911a8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/common/src/directives/ng_optimized_image/image_loaders/imagekit_loader.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@ export function createImagekitUrl(path: string, config: ImageLoaderConfig): stri
4545
// Example of an ImageKit image URL:
4646
// https://ik.imagekit.io/demo/tr:w-300,h-300/medium_cafe_B1iTdD0C.jpg
4747
const {src, width} = config;
48-
let urlSegments: string[];
48+
const urlSegments: string[] = [path, src];
49+
const params: string[] = [];
4950

5051
if (width) {
51-
const params = `tr:w-${width}`;
52-
urlSegments = [path, params, src];
53-
} else {
54-
urlSegments = [path, src];
52+
params.push(`w-${width}`);
5553
}
5654

57-
const url = new URL(urlSegments.join('/'));
58-
5955
// When requesting a placeholder image we ask for a low quality image to reduce the load time.
6056
if (config.isPlaceholder) {
61-
url.searchParams.set('q', PLACEHOLDER_QUALITY);
57+
params.push(`q-${PLACEHOLDER_QUALITY}`);
58+
}
59+
60+
if (params.length) {
61+
urlSegments.splice(1, 0, `tr:${params.join(',')}`);
6262
}
63+
64+
const url = new URL(urlSegments.join('/'));
6365
return url.href;
6466
}

0 commit comments

Comments
 (0)