Skip to content

Commit

Permalink
fix(cloudinary): default to fill without upscale (#27)
Browse files Browse the repository at this point in the history
* fix(cloudinary): default to fill without upscale

* chore: fix test
  • Loading branch information
ascorbic authored Mar 9, 2023
1 parent 46c56d1 commit e7a3de5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/transformers/cloudinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Deno.test("cloudinary transformer", async (t) => {
});
assertEquals(
result?.toString(),
"https://res.cloudinary.com/demo/image/upload/w_100,h_200,f_auto/dog",
"https://res.cloudinary.com/demo/image/upload/w_100,h_200,c_lfill,f_auto/dog",
);
});

Expand Down
6 changes: 4 additions & 2 deletions src/transformers/cloudinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const parse: UrlParser<CloudinaryParams> = (

const group = matches[0].groups || {};
const {
transformations: transformString,
transformations: transformString = "",
format: originalFormat,
...baseParams
} = group;
Expand Down Expand Up @@ -104,13 +104,15 @@ export const generate: UrlGenerator<CloudinaryParams> = (
...params,
format: format || "auto",
};

if (width) {
props.transformations.w = roundIfNumeric(width).toString();
}
if (height) {
props.transformations.h = roundIfNumeric(height).toString();
}

// Default crop to fill without upscaling
props.transformations.c ||= "lfill";
return new URL(formatUrl(props));
};

Expand Down
2 changes: 1 addition & 1 deletion src/transformers/storyblok.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Deno.test("storyblok parser", async (t) => {
for (const image of images) {
await t.step(image, () => {
const res = parse(image);
console.log(res);
// console.log(res);
});
// await t.step(original, () => {
// const { params, ...parsed } = parse(original ) as any;
Expand Down

0 comments on commit e7a3de5

Please sign in to comment.