Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ function createCloudinaryUrl(path: string, config: ImageLoaderConfig) {
params += `,w_${config.width}`;
}

if (config.loaderParams?.['rounded']) {
params += `,r_max`;
}

return `${path}/image/upload/${params}/${config.src}`;
}
10 changes: 10 additions & 0 deletions packages/common/test/image_loaders/image_loader_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ describe('Built-in image directive loaders', () => {
expect(loader({src: '/img.png'})).toBe(`${path}/image/upload/f_auto,q_auto/img.png`);
});
});

describe('config validation', () => {
it('should add the r_max cloudinary transformation to the URL when the rounded option is provided', () => {
const path = 'https://res.cloudinary.com/mysite';
const loader = createCloudinaryLoader(path);
expect(loader({src: '/img.png', loaderParams: {rounded: true}})).toBe(
`${path}/image/upload/f_auto,q_auto,r_max/img.png`,
);
});
});
});

describe('ImageKit loader', () => {
Expand Down