Class: Cloudinary

Cloudinary


new Cloudinary(options)

Main Cloudinary class

Parameters:
Name Type Description
options Object

options to configure Cloudinary

See:
  • Configuration for more details
Example
var cl = new cloudinary.Cloudinary( { cloud_name: "mycloud"});
   var imgTag = cl.image("myPicID");

Members


<static, constant> DEFAULT_IMAGE_PARAMS :Object

Defaults values for image parameters.

(Previously defined using option_consume() )

Type:
  • Object

<static, constant> DEFAULT_VIDEO_PARAMS :Object

Defaults values for video parameters.

Type:
  • Object

Methods


.toHtmlAttributes()

Returns attributes for an HTML tag.

Returns:

PlainObject


#cloudinary_update(elements, options)

Update hidpi (dpr_auto) and responsive (w_auto) fields according to the current container size and the device pixel ratio. Only images marked with the cld-responsive class have w_auto updated.

Parameters:
Name Type Description
elements Array | string | NodeList

the elements to modify

options Object
Properties
Name Type Argument Default Description
responsive_use_breakpoints boolean | string <optional>
true
  • when true, always use breakpoints for width
  • when "resize" use exact width on first render and breakpoints on resize
  • when false always use exact width
responsive boolean <optional>

if true, enable responsive on this element. Can be done by adding cld-responsive.

responsive_preserve_height boolean <optional>

if set to true, original css height is preserved. Should only be used if the transformation supports different aspect ratios.


#facebook_profile_image(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#fetch_image(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#gravatar_image(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#image(publicId, options)

Generate an image tag.

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#imageTag(publicId, options)

Creates a new ImageTag instance, configured using this own's configuration.

Parameters:
Name Type Description
publicId string

the public ID of the resource

options Object

additional options to pass to the new ImageTag instance

Returns: ImageTag

An ImageTag that is attached (chained) to this Cloudinary instance

Type
ImageTag

#init()

Initialize configuration.

See:
Returns: Cloudinary

this for chaining

Type
Cloudinary

#normalize(expression)

Normalize a string expression

Parameters:
Name Type Description
expression string

a expression, e.g. "w gt 100", "width_gt_100", "width > 100"

Returns: string

the normalized form of the value expression, e.g. "w_gt_100"

Type
string

#processImageTags(nodes, options)

Finds all img tags under each node and sets it up to provide the image through Cloudinary

Parameters:
Name Type Argument Default Description
nodes Array.<Element>

the parent nodes to search for img under

options Object <optional>
{}

options and transformations params


#responsive(options, bootstrap)

Initialize the responsive behaviour.
Calls Cloudinary#cloudinary_update to modify image tags.

Parameters:
Name Type Argument Default Description
options Object
Properties
Name Type Argument Default Description
responsive_class String <optional>
'cld-responsive'

provide an alternative class used to locate img tags

responsive_debounce number <optional>
100

the debounce interval in milliseconds.

bootstrap boolean <optional>
true

if true processes the img tags by calling cloudinary_update. When false the tags will be processed only after a resize event.

See:

#sprite_css(publicId, options)

Generate the URL of the sprite image

Parameters:
Name Type Argument Description
publicId string

the public ID of the resource

options Object <optional>

options for the tag and transformations

See:

#transformation(options)

Provide a transformation object, initialized with own's options, for chaining purposes.

Parameters:
Name Type Description
options Object
Returns: Transformation
Type
Transformation

#transformation_string(options)

Generate a string representation of the provided transformation options.

Parameters:
Name Type Description
options Object

the transformation options

Returns: string

The transformation string

Type
string

#twitter_name_profile_image(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#twitter_profile_image(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#url(publicId, options)

Generate an resource URL.

Parameters:
Name Type Argument Description
publicId string

the public ID of the resource

options Object <optional>

options for the tag and transformations, possible values include all Transformation parameters and Configuration parameters

Properties
Name Type Argument Default Description
type string <optional>
'upload'

the classification of the resource

resource_type Object <optional>
'image'

the type of the resource

Returns: string

The resource URL

Type
string

#video(publicId, options)

Parameters:
Name Type Argument Description
publicId string

the public ID of the image

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

an image tag element

Type
HTMLImageElement

#video_thumbnail(publicId, options)

Generate an image tag for the video thumbnail.

Parameters:
Name Type Argument Description
publicId string

the public ID of the video

options Object <optional>

options for the tag and transformations

Returns: HTMLImageElement

An image tag element

Type
HTMLImageElement

#video_thumbnail_url(publicId, options)

Generate an video thumbnail URL.

Parameters:
Name Type Argument Description
publicId string

the public ID of the resource

options Object <optional>

options for the tag and transformations, possible values include all Transformation parameters and Configuration parameters

Properties
Name Type Argument Default Description
type string <optional>
'upload'

the classification of the resource

Returns: string

The video thumbnail URL

Type
string

#video_url(publicId, options)

Generate an video resource URL.

Parameters:
Name Type Argument Description
publicId string

the public ID of the resource

options Object <optional>

options for the tag and transformations, possible values include all Transformation parameters and Configuration parameters

Properties
Name Type Argument Default Description
type string <optional>
'upload'

the classification of the resource

Returns: string

The video URL

Type
string

#videoTag(publicId, options)

Creates a new VideoTag instance, configured using this own's configuration.

Parameters:
Name Type Description
publicId string

the public ID of the resource

options Object

additional options to pass to the new VideoTag instance

Returns: VideoTag

A VideoTag that is attached (chained) to this Cloudinary instance

Type
VideoTag