Skip to content

Commit 3507969

Browse files
author
Maya Shavin
committed
doc: update docs with new api
1 parent 080d9df commit 3507969

5 files changed

Lines changed: 97 additions & 35 deletions

File tree

docs/url-docs/content/en/examples/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Advanced
33
description: 'Advanced examples to use Cloudinary url builder'
4-
position: 7
4+
position: 8
55
category: Examples
66
---
77

docs/url-docs/content/en/examples/basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Basic
33
description: 'Basic examples to use Cloudinary url builder'
4-
position: 6
4+
position: 7
55
category: Examples
66
---
77

docs/url-docs/content/en/options.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Options
33
description: 'Configuration options for Cloudinary url builder'
44
position: 3
55
category: Guide
6+
version: 1
67
---
78

89
To configure the builder globally, you can use `setConfig()` method:
@@ -29,6 +30,8 @@ const src = buildImageUrl('public-id', {
2930

3031
## Cloudinary options
3132

33+
* Type: `CloudConfig`
34+
3235
### `cloudName`
3336

3437
* Type: `String`

docs/url-docs/content/en/usage/transformations.md

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ title: Transformations
33
description: 'Supported transformation fields'
44
position: 5
55
category: Usage
6+
version: 1
67
---
78

8-
To transform and optimize your images and videos on delivery, you can pass the following fields to `options.transformations` in each build url method call.
9+
To transform and optimize your images and videos on delivery, you can pass the following fields to `options.transformations` in each build url method call or `options` in `Transformer.transform` call.
910

1011
<alert type="info">
1112

@@ -52,7 +53,7 @@ See [Resize type](https://cloudinary.com/documentation/image_transformation_refe
5253

5354
### `rotation`
5455

55-
* Type: `String` | `Number`
56+
* Type: `Rotation`
5657
* Accepted values: any degree number, or `auto_right` | `auto_left` | `ignore` | `vflip` | `hflip`
5758

5859
To rotate or flip a given asset by certain degrees, or automatically based on orientation.
@@ -70,6 +71,12 @@ const url = buildImageUrl('example', {
7071
})
7172
```
7273

74+
<alert type="info">
75+
76+
You can use import `ROTATION_MODES` from `cloudinary-build-url` to choose the desired rotation mode.
77+
78+
</alert>
79+
7380
### `background`
7481

7582
* Type: `String`
@@ -118,7 +125,8 @@ const url = buildImageUrl('example', {
118125

119126
### `effect`
120127

121-
* Type: `String`
128+
* Type: `Effect`
129+
* An available effect or array of effects to apply to asset.
122130

123131
Apply a filter or an effect on the desired asset. See[Effects](https://cloudinary.com/documentation/image_transformation_reference#effect_parameter) for the full list of syntax and available effects.
124132

@@ -221,7 +229,7 @@ const url = buildImageUrl('example', {
221229

222230
* Type: `String`
223231

224-
Create a layer over the base image. This can be use with `x`, `y`, `gravity` to customize the position of the overlay.
232+
Create a layer over the base image. This can be use with `position.x`, `position.y`, `gravity` to customize the position of the overlay.
225233

226234
```js
227235
import { buildImageUrl } from 'cloudinary-build-url'
@@ -241,7 +249,7 @@ const url = buildImageUrl('face_top', {
241249

242250
* Type: `String`
243251

244-
Create a layer below a partial-transparent image. This can be use with `x`, `y`, `gravity` to customize the position of the underlay.
252+
Create a layer below a partial-transparent image. This can be use with `position.x`, `position.y`, `gravity` to customize the position of the underlay.
245253

246254
```js
247255
import { buildImageUrl } from 'cloudinary-build-url'
@@ -545,11 +553,15 @@ const url = buildImageUrl('example', {
545553
})
546554
```
547555

548-
### `x`
556+
### `position`
549557

550-
* Type: `Number`
551-
552-
Horizontal coordinate for cropping, placing overlay and applying regional effects.
558+
* Type: `Position`
559+
* `x`
560+
* Type: `number`
561+
* Horizontal coordinate for cropping, placing overlay and applying regional effects.
562+
* `y`
563+
* Type: `Number`
564+
* Vertical coordinate for cropping, placing overlay and applying regional effects.
553565

554566
```js
555567
import { buildImageUrl } from 'cloudinary-build-url'
@@ -559,31 +571,10 @@ const url = buildImageUrl('face-top', {
559571
cloudName: 'demo',
560572
},
561573
transformations: {
562-
x: 130,
563-
resize: {
564-
width: 80,
565-
height: 80,
566-
type: 'crop'
574+
position: {
575+
x: 130,
576+
y: 340
567577
}
568-
}
569-
})
570-
```
571-
572-
### `y`
573-
574-
* Type: `Number`
575-
576-
Vertical coordinate for cropping, placing overlay and applying regional effects.
577-
578-
```js
579-
import { buildImageUrl } from 'cloudinary-build-url'
580-
581-
const url = buildImageUrl('face-top', {
582-
cloud: {
583-
cloudName: 'demo',
584-
},
585-
transformations: {
586-
y: 340,
587578
resize: {
588579
width: 80,
589580
height: 80,
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
title: Transformer
3+
description: 'Generate the set of Cloudinary transformations'
4+
position: 6
5+
category: Usage
6+
version: 1
7+
---
8+
9+
In addition to the build URL API, the package exposes an instance of `Transformer`, which can be used to calculate transformations independently.
10+
11+
## `Transformer.transform(options)`
12+
13+
* `options`:
14+
* Type: `TransformerOption`
15+
* **Required**
16+
* Object contains all the accepted transformation keys and values to to generate.
17+
* Output:
18+
* Type: `Transformation`
19+
20+
Returns an array of mapped transformation params according to Cloudinary format.
21+
22+
```js
23+
import { Transformer } from 'cloudinary-build-url
24+
25+
const transArr = Transformer.transform({
26+
resize: {
27+
width: 500,
28+
height: 500,
29+
type: 'thumb'
30+
},
31+
gravity: 'auto',
32+
chaining: [{
33+
effect: 'grayscale'
34+
}]
35+
})
36+
37+
console.log(transArr)
38+
//['c_thumb','w_500', 'h_500', 'g_auto', ['e_grayscale']]
39+
```
40+
41+
See [Transformations](/usage/transformations) for more details on accepted properties for `options`.
42+
43+
## `Transformer.toString(transformations)`
44+
45+
* `transformations`:
46+
* Type: `Transformation`
47+
* Array of transformation params according to Cloudinary format.
48+
* Output:
49+
* Type: `String`
50+
51+
Returns a string that contains all the given transformations, separated by `,` or `/` and ready to inject to Cloudinary image URL.
52+
53+
```js
54+
import { Transformer } from 'cloudinary-build-url'
55+
56+
const trans = Transformer.toString([
57+
'c_thumb',
58+
'w_500',
59+
'h_500',
60+
'g_auto',
61+
[ 'e_grayscale' ]
62+
])
63+
64+
console.log(trans)
65+
//'c_thumb,w_500,h_500,g_auto/e_grayscale'
66+
```
67+
68+
See [Image Transformation API](https://cloudinary.com/documentation/image_transformation_reference) for more details on how to compute transformation params.

0 commit comments

Comments
 (0)