Skip to content

Transformation method parameters all missing | string #32

@danieltott

Description

@danieltott

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions