SDK Terminology
The best way to explain our terminology is through an example
import {Cloudinary} from "@cloudinary/url-gen/instance/Cloudinary";
import {Rotate} from "@cloudinary/url-gen/actions/rotate";
import {Resize} from "@cloudinary/url-gen/actions/resize";
import {RotationMode} from "@cloudinary/url-gen/qualifiers/rotationMode";
// Create your instance
const cld = new Cloudinary({
cloud: {
cloudName: 'demo'
},
url: {
secure: true // force https, set to false to force http
}
});
const myImage = cld.image('sample');
myImage
.resize(
Resize.scale()
.width(100)
.height(100))
.rotate(
Rotate.mode(RotationMode.verticalFlip())
);
Cloudinary Instance & Configuration
- The first step in every new application will be creating a new Cloudinary Instance
- The SDK has two types of Transformations - CloudinaryImage and VideoTransformation
- Use the instance you created to generate a new CloudinaryImage / new VideoTransformation instance
- The
Cloudinary Configuration
is used to define how URLs are created
Actions and ActionGroups
- Assets expose methods called ActionGroups (
image.resize
,image.rotate
) - ActionGroups receive an Action as a parameter
- We create Action objects through Factory methods (
scale
,mode
) - You can find more Actions in
'@cloudinary/url-gen/actions'
- You can import all actions from
import {Actions} from '@cloudinary/url-gen'
Qualifiers and QualifierValues
- Actions expose methods to define their behaviours
- We call the Methods on Actions Qualifiers
- Qualifiers usually accept a QualifierValue
- QualifierValues can be primitive (numbers, strings) or predefined SDK values that can be imported
- Almost all QualifierValues are functions (RotationMode.verticalFlip())
- You can find more QualifierValues in
'@cloudinary/url-gen/values'
Generalized form
asset.actionGroup(actionGroup.action(mandatoryQualifier).qualifier1().qualifier2())
Resizing example (No mandatory Qualifier)
myImage.resize(Resize.scale().width(100).height(100))