Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation method parameters all missing | string #32

Open
danieltott opened this issue Oct 6, 2023 · 0 comments · May be fixed by #33
Open

Transformation method parameters all missing | string #32

danieltott opened this issue Oct 6, 2023 · 0 comments · May be fixed by #33

Comments

@danieltott
Copy link

I'm working on an issue (cloudinary-community/cloudinary-util#53) that makes use of CloudinaryImage.effect()

The current version passes a string (and it works without typing (ie using any)), but CloudinaryImage.effect only takes EffectActions. I couldn't figure out how it still worked until I got here.

Cloudinary.effect() is basically passed straight through to Transformation.effect here:

effect(effectAction: EffectActions): this {
return this.addAction(effectAction);
}

Which in turn is passed straight to Transformation.addAction.

addAction(action: Action | string): this {
let actionToAdd: Action | RawAction;
if (typeof action === 'string') {
if (action.indexOf('/') >= 0) {
throw 'addAction cannot accept a string with a forward slash in it - /, use .addTransformation() instead';
} else {
actionToAdd = new RawAction(action);
}
} else {
actionToAdd = action;
}
this.actions.push(actionToAdd);
return this;
}

The original call worked with a string because addAction takes a string or an Action, which seems really good. Many Cloudinary users I expect are used to thinking about string values for these things, or at least would expect that to work (ie img.effect('e_tint:40:253f8c)alongsideimg.effect(Adjust.tint('40:253f8c'))`.

Proposed solution:

Update all of the methods for Transformation that pass their parameters along to addAction to accept a string as well as their assigned transform type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant