Skip to content
Open
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
6 changes: 3 additions & 3 deletions packages/url-loader/src/plugins/cropping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ function collectTransformations(collectOptions: CroppingPlugin.NestedOptions) {
transformations.push(`w_${width}`);
}

// Some crop types don't need a height and will resize based
// on the aspect ratio
// Skip explicit height when using aspect ratio (which determines height automatically)
// Otherwise, include explicit height when provided

if (!["limit"].includes(crop) && typeof height === "number") {
if (typeof height === "number" && !hasValidAspectRatio) {
transformations.push(`h_${height}`);
}

Expand Down
30 changes: 15 additions & 15 deletions packages/url-loader/tests/lib/cloudinary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("Cloudinary", () => {
},
});
expect(url).toContain(
`https://res.cloudinary.com/${cloudName}/image/upload/c_limit,w_100/f_auto/q_auto/v1/turtle`,
`https://res.cloudinary.com/${cloudName}/image/upload/c_limit,w_100,h_100/f_auto/q_auto/v1/turtle`,
);
});

Expand All @@ -51,7 +51,7 @@ describe("Cloudinary", () => {
},
});
expect(url).toContain(
`https://res.cloudinary.com/${cloudName}/${assetType}/upload/c_limit,w_100/f_auto/q_auto/v1/turtle`,
`https://res.cloudinary.com/${cloudName}/${assetType}/upload/c_limit,w_100,h_100/f_auto/q_auto/v1/turtle`,
);
});

Expand All @@ -77,7 +77,7 @@ describe("Cloudinary", () => {
},
});
expect(url).toContain(
`https://res.cloudinary.com/${cloudName}/image/upload/c_limit,w_100/f_${format}/q_${quality}/v1/turtle`,
`https://res.cloudinary.com/${cloudName}/image/upload/c_limit,w_100,h_100/f_${format}/q_${quality}/v1/turtle`,
);
});

Expand All @@ -86,7 +86,7 @@ describe("Cloudinary", () => {
const deliveryType = "upload";
const publicId = "myimage";

const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/v1234/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/v1234/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -112,7 +112,7 @@ describe("Cloudinary", () => {
const publicId = "myimage";
const dpr = "2.0";

const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/dpr_${dpr}/f_auto/q_auto/v1/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/dpr_${dpr}/f_auto/q_auto/v1/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -137,7 +137,7 @@ describe("Cloudinary", () => {
const publicId = "myimage";
const dpr = 2;

const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/dpr_${dpr.toFixed(1)}/f_auto/q_auto/v1/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/dpr_${dpr.toFixed(1)}/f_auto/q_auto/v1/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -161,7 +161,7 @@ describe("Cloudinary", () => {
const publicId = "myimage";
const dpr = "auto";

const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/dpr_${dpr}/f_auto/q_auto/v1/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/dpr_${dpr}/f_auto/q_auto/v1/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand Down Expand Up @@ -260,7 +260,7 @@ describe("Cloudinary", () => {
},
});
expect(url).toContain(
`https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/f_auto/q_auto/v1/${src}`,
`https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/f_auto/q_auto/v1/${src}`,
);
});

Expand All @@ -269,7 +269,7 @@ describe("Cloudinary", () => {
const deliveryType = "fetch";
const publicId = "myimage";

const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/f_auto/q_auto/v1234/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/f_auto/q_auto/v1234/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -293,7 +293,7 @@ describe("Cloudinary", () => {
const deliveryType = "fetch";
const publicId = "myimage";

const src = `res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100/f_auto/q_auto/v1234/${publicId}?_a=`;
const src = `res.cloudinary.com/${cloudName}/image/${deliveryType}/c_limit,w_100,h_100/f_auto/q_auto/v1234/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("Cloudinary", () => {
const publicId = "myimage";
const seoSuffix = "test-image";

const src = `https://res.cloudinary.com/${cloudName}/images/c_limit,w_100/f_auto/q_auto/v1234/${publicId}/${seoSuffix}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/images/c_limit,w_100,h_100/f_auto/q_auto/v1234/${publicId}/${seoSuffix}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -392,7 +392,7 @@ describe("Cloudinary", () => {
const width = 1234;
const height = 1234;

const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_${width}/f_auto/q_auto/v1234/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_${width},h_${height}/f_auto/q_auto/v1234/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -419,8 +419,8 @@ describe("Cloudinary", () => {
const width = 1234;
const height = 1234;

const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_${width}/f_auto/q_auto/v1234/${publicId}/${seoSuffix}${format}?_i=A`;
const exepectedSrc = `https://res.cloudinary.com/${cloudName}/image/fetch/c_limit,w_${width}/f_auto/q_auto/v1234/${publicId}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_${width},h_${height}/f_auto/q_auto/v1234/${publicId}/${seoSuffix}${format}?_i=A`;
const exepectedSrc = `https://res.cloudinary.com/${cloudName}/image/fetch/c_limit,w_${width},h_${height}/f_auto/q_auto/v1234/${publicId}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand All @@ -446,7 +446,7 @@ describe("Cloudinary", () => {
const originalSeoSuffix = "my-image";
const seoSuffix = "test-image";

const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_100/f_auto/q_auto/v1234/${publicId}/${originalSeoSuffix}?_a=`;
const src = `https://res.cloudinary.com/${cloudName}/${assetType}/c_limit,w_100,h_100/f_auto/q_auto/v1234/${publicId}/${originalSeoSuffix}?_a=`;

const url = constructCloudinaryUrl({
options: {
Expand Down