Skip to content

Commit 53427d8

Browse files
johnnygerardthePunderWoman
authored andcommitted
fix(common): invalid ImageKit quality parameter (#55193)
The current quality parameter is ignored by ImageKit. PR Close #55193
1 parent 9cb1d27 commit 53427d8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,18 @@ 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 params: string[] = [];
4949

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

57-
const url = new URL(urlSegments.join('/'));
58-
5954
// When requesting a placeholder image we ask for a low quality image to reduce the load time.
6055
if (config.isPlaceholder) {
61-
url.searchParams.set('q', PLACEHOLDER_QUALITY);
56+
params.push(`q-${PLACEHOLDER_QUALITY}`);
6257
}
58+
59+
const urlSegments = params.length ? [path, `tr:${params.join(',')}`, src] : [path, src];
60+
const url = new URL(urlSegments.join('/'));
6361
return url.href;
6462
}

0 commit comments

Comments
 (0)