Options
To configure the builder globally, you can use setConfig()
method:
import { setConfig } from 'cloudinary-build-url'
setConfig({
cloudName: 'your-cloud-name',
})
To configure the builder per url generation call, you can use cloud
field of options
parameter of that call.
import { buildImageUrl } from 'cloudinary-build-url'
const src = buildImageUrl('public-id', {
cloud: {
cloudName: 'your-cloud-name',
}
})
Cloudinary options
- Type:
CloudConfig
cloudName
- Type:
String
- Required
The cloud name associated with your Cloudinary account. It is used to configure and enable Cloudinary features such as generating delivery asset URL.
import { setConfig } from 'cloudinary-build-url'
setConfig({
cloudName: 'your-cloud-name',
})
Cloud name presents in every delivered URL from Cloudinary, hence it's important to have it configured correctly.
You can find your cloud name details in Dashboard page, or in Account Settings page in Cloudinary console
secure
- Type:
Boolean
- Default:
true
Force secure HTTPS delivery urls for all assets (images + videos) generated by Cloudinary, even if they are embedded in HTTP originally.
Disable this flag to have all delivery urls built with HTTP protocol instead.
import { setConfig } from 'cloudinary-build-url'
setConfig({
secure: false
})
secureDistribution
- Type:
String
- Relevant only when
secure
istrue
Set custom domain name for building secure HTTPS urls.
import { setConfig } from 'cloudinary-build-url'
setConfig({
secureDistribution: 'your-custome-domain-name'
})
Only relevant if you are Advanced plan Cloudinary user with private CDN distribution and custom CNAME set. You can see more details here
cname
- Type:
String
- Use only when
secure
isfalse
Set custom domain name for building non-secure HTTP urls.
import { setConfig } from 'cloudinary-build-url'
setConfig({
cname: 'your-custome-domain-name'
})
Only relevant if you are Advanced plan Cloudinary user with private CDN distribution and custom CNAME set. You can see more details here
privateCdn
- Type:
Boolean
- Default:
false
Set to true
if you'd like to use private CDN distribution.
import { setConfig } from 'cloudinary-build-url'
setConfig({
privateCDN: true
})
Only relevant for Advanced plan Cloudinary users. You can see more details here
Asset options
Below are the configuration options to apply to assets specifically (images and videos).
storageType
- Type:
String
- Default:
upload
- Accepted values:
upload
|fetch
|private
|authenticated
|sprite
|facebook
|twitter
|youtube
|vimeo
The storage and delivery type of asset in Cloudinary.
import { setConfig } from 'cloudinary-build-url'
import { STORAGE_TYPES } from '@cld-apis/utils'
setConfig({
storageType: STORAGE_TYPES.UPLOAD //upload
})
STORAGE_TYPES
contains all the valid storage types.
resourceType
- Type:
String
- Default:
image
- Accepted values:
image
|video
|raw
Type of the asset(s)
import { setConfig } from 'cloudinary-build-url'
import { RESOURCE_TYPES } from '@cld-apis/utils'
setConfig({
storageType: RESOURCE_TYPES.IMAGE //image
})
RESOURCE_TYPES
contains all the valid resources types.
version
- Type:
Number
|String
- Default:
1
The timestamp of uploaded asset. If there is no version indicated, a previously cache version of asset will be served instead.
It's only relevant to uploaded asset to Cloudinary.
import { setConfig } from 'cloudinary-build-url'
setConfig({
version: 1312461204
})
To use version
, you need to have forceVersion
enabled.
forceVersion
- Type:
Boolean
- Default:
false
To enable applying version on asset whenever possible. It's only relevant to uploaded asset to Cloudinary.
import { setConfig } from 'cloudinary-build-url'
setConfig({
forceVersion: true
})
signature
- Type:
String
A string includes all the components of the delivery URL that will come after the signature component.
import { setConfig } from 'cloudinary-build-url'
setConfig({
signature: 'my-signature'
})
See Signature Documentation for more details.