Variable

Description

Defines a new user variable with the given value.

Examples

			import {Cloudinary} from "@cloudinary/url-gen/instance/Cloudinary";
			import {
			 set,
			 setAssetReference,
			 setFromContext,
			 setFromMetadata
			} from "@cloudinary/url-gen/actions/variable";
			import {scale} from "@cloudinary/url-gen/actions/resize";
			
			const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
			
			const image = yourCldInstance.image('woman');
			image
			 .addVariable(set('foo1', 100))
			 .addVariable(setAssetReference('foo2', 'val'))
			 .addVariable(setFromContext('foo3', 'val'))
			 .addVariable(setFromMetadata('foo4', 'val'))
			 .resize(scale().width('$foo1').height('$foo2'))
Details

Classes


new SetAssetReferenceAction()


new SetFromContextAction()


new SetFromMetadataAction()


new SetAction()


new VariableAction()

Methods


<static> set( name, value ) → {Actions.Variable.SetAction}

action

Description

Sets a new user variable with the given value.

Parameters
Name Type Description
name string

Variable name

value number | string | Array.<number> | Array.<string>

Variable value

Details

<static> setFloat( name, value ) → {Actions.Variable.SetAction}

action

Description

Same as 'set', but forces the end value to be a float setFloat(1) will result in $foo_1.0

Parameters
Name Type Description
name string

Variable name

value number

Variable value

Details

<static> setInteger( name, value ) → {Actions.Variable.SetAction}

action

Description

Same as 'set', but forces the end value to be an integer setInteger(1.1) will result in $foo_1, input is rounded down

Parameters
Name Type Description
name string

Variable name

value number

Variable value

Details

<static> setString( name, value ) → {Actions.Variable.SetAction}

action

Description

Same as 'set', but forces the end value to be a string setString(1) will result in $foo_!1!

Parameters
Name Type Description
name string | number

Variable name

value number

Variable value

Details

<static> setAssetReference( name, value ) → {Actions.Variable.SetAssetReferenceAction}

action

Description

Allows adding a variable by sending a key and value which is a reference to an asset.

Parameters
Name Type Description
name string
value string
Details

<static> setFromContext( name, value ) → {Actions.Variable.SetFromContextAction}

action

Description

Allows adding a variable by sending a key and value which is a key to a value that assumed to be on the asset’s context.

Parameters
Name Type Description
name string
value string
Details

<static> setFromMetadata( name, value ) → {Actions.Variable.SetFromMetadataAction}

action

Description

Allows adding a variable by sending a name and value which is a key to a value that assumed to be on the predefined account’s metadata fields.

Parameters
Name Type Description
name string
value string
Details