Methods
cacheResults(result, options)
Cache (part of) the upload results.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
result |
|||||||||||
options |
object |
Properties
|
- Source:
(private) chainTransformations(options, transformation)
Helper function, allows chaining transformation to the end of transformation list
Parameters:
Name | Type | Description |
---|---|---|
options |
object | Original options |
transformation |
object | Array.<object> | Transformations to chain at the end |
- Source:
Returns:
array Resulting options
(private) crc32(str) → {number|*}
Compute the crc32 checksum if the given string
Parameters:
Name | Type | Description |
---|---|---|
str |
string |
- Source:
Returns:
- Type
- number | *
(private) defaults(defaults) → {function}
Returns an ensureOption function that relies on the provided `defaults` argument
for default values.
Parameters:
Name | Type | Description |
---|---|---|
defaults |
object |
- Source:
Returns:
- Type
- function
(private) ensurePresenceOf(parameters)
Validate that the given values are defined
Parameters:
Name | Type | Description |
---|---|---|
parameters |
object | where each key value pair is the name and value of the argument to validate. |
- Source:
Example
function foo(bar){
ensurePresenceOf({bar});
// ...
}
(private) generateImageResponsiveAttributes(publicId, attributes, srcsetData, options)
Helper function. Generates srcset and sizes attributes of the image tag
Generated attributes are added to attributes argument
Parameters:
Name | Type | Description |
---|---|---|
publicId |
string | The public ID of the resource |
attributes |
object | Existing HTML attributes. |
srcsetData |
srcset | |
options |
object | Additional options. |
- Source:
Returns:
array The responsive attributes
(private) generateMediaAttr(options) → {string}
Generate a media query
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | configuration options
Properties
|
- Source:
Returns:
a media query string
- Type
- string
(private) generateSizesAttribute(srcsetData) → {string}
Helper function. Generates sizes attribute value of the HTML img tag
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
srcsetData |
object | string |
Properties
|
- Source:
Returns:
Resulting sizes attribute value
- Type
- string
(private) generateSrcsetAttribute(public_id, breakpoints, transformation, options) → {string}
Helper function. Generates srcset attribute value of the HTML img tag
Parameters:
Name | Type | Description |
---|---|---|
public_id |
string | Public ID of the resource |
breakpoints |
Array.<number> | An array of breakpoints (in pixels) |
transformation |
object | The transformation |
options |
object | Includes html tag options, transformation options |
- Source:
Returns:
Resulting srcset attribute value
- Type
- string
get() → {CacheAdapter}
Returns:
The current cache adapter
- Type
- CacheAdapter
getOrGenerateBreakpoints(srcset, public_id, options) → {*|Array}
If cache is enabled, get the breakpoints from the cache. If the values were not found in the cache,
or cache is not enabled, generate the values.
Parameters:
Name | Type | Description |
---|---|---|
srcset |
srcset | The srcset configuration parameters |
public_id |
string | |
options |
object |
- Source:
Returns:
- Type
- * | Array
image(source, options) → {string}
Generate an HTML img tag with a Cloudinary URL
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source |
string | A Public ID or a URL | |||||||||||||||||||||||||||
options |
object | Configuration options
Properties
|
- Source:
Returns:
An HTML img tag
- Type
- string
module:auth_token(options) → {string}
Generate an authorization token
Parameters:
Name | Type | Description |
---|---|---|
options |
authTokenOptions |
- Source:
Returns:
the authorization token
- Type
- string
picture(public_id, options) → {string}
Generate a
The sources argument defines different transformations to apply for each media query.
picture
HTML tag.The sources argument defines different transformations to apply for each media query.
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public_id |
string | |||||||||||||||||||
options |
object |
Properties
|
- Source:
Returns:
A picture HTML tag
- Type
- string
Example
cloudinary.picture("sample", {
sources: [
{min_width: 1600, transformation: {crop: 'fill', width: 800, aspect_ratio: 2}},
{min_width: 500, transformation: {crop: 'fill', width: 600, aspect_ratio: 2.3}},
{transformation: {crop: 'crop', width: 400, gravity: 'auto'}},
]}
);
rimraf(dir_path)
Remove directory recursively
Parameters:
Name | Type | Description |
---|---|---|
dir_path |
string |
set(adapter)
Set the cache adapter to be used by Cache
Parameters:
Name | Type | Description |
---|---|---|
adapter |
CacheAdapter | Cache adapter |
source(public_id, options) → {string}
Generate a
source
tag.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public_id |
string | ||||||||||
options |
object |
Properties
|
- Source:
Returns:
- Type
- string
(private) srcsetUrl(public_id, width, transformation, options) → {string}
Helper function. Generates a single srcset item url
Parameters:
Name | Type | Description |
---|---|---|
public_id |
string | Public ID of the resource. |
width |
number | Width in pixels of the srcset item. |
transformation |
object | string | |
options |
object | Additional options. |
- Source:
Returns:
Resulting URL of the item
- Type
- string
video(public_id, optionsopt) → {string}
Creates an HTML video tag for the provided public_id
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public_id |
String | the resource public ID | |||||||||||||||||
options |
Object |
<optional> |
options for the resource and HTML tag
Properties
|
- Source:
Returns:
HTML video tag
- Type
- string
Example
Example of generating a video tag:
cloudinary.video("mymovie.mp4");
cloudinary.video("mymovie.mp4", {source_types: 'webm'});
cloudinary.video("mymovie.ogv", {poster: "myspecialplaceholder.jpg"});
cloudinary.video("mymovie.webm", {source_types: ['webm', 'mp4'], poster: {effect: 'sepia'}});
Type Definitions
srcset
Options used to generate the srcset attribute.
Type:
- object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
breakpoints |
Array.<number> | Array.<string> |
<optional> |
An array of breakpoints. |
min_width |
number |
<optional> |
Minimal width of the srcset images. |
max_width |
number |
<optional> |
Maximal width of the srcset images. |
max_images |
number |
<optional> |
Number of srcset images to generate. |
transformation |
object | string |
<optional> |
The transformation to use in the srcset urls. |
sizes |
boolean |
<optional> |
Whether to calculate and add the sizes attribute. |
- Source: