Build Url

To generate delivery urls with transformations for assets using Cloudinary, you can use the following methods:

buildUrl(publicId, options)

  • publicId
    • Type: String
    • Required
    • Path to the asset stored in Cloudinary, or the full Cloudinary asset URL.
  • options
    • Type: CldOptions
    • Consists two fields: cloud and transformations. See the options parameter for more details.

Generate delivery URL for an asset with publicId and given options, including options.cloud extra configurations, and options.transformations - the transformations to apply.

import { buildUrl } from 'cloudinary-build-url'

const url = buildUrl('example', {
  cloud: {
    cloudName: 'demo',
  },
  transformations: {
    resize: {
      type: 'scale',
      width: 500,
      height: 500,
    }
  }
})

buildImageUrl(publicId, options)

  • publicId
    • Type: String
    • Required
    • Path to the image stored in Cloudinary, or the full Cloudinary image URL.
  • options
    • Type: CldOptions
    • Consists two fields: cloud and transformations. See the options parameter for more details.

Generate delivery URL for an image with publicId and given options, including options.cloud extra configurations, and options.transformations - the transformations to apply.

import { buildImageUrl } from 'cloudinary-build-url'

const url = buildImageUrl('example', {
  cloud: {
    cloudName: 'demo',
  },
  transformations: {
    resize: {
      type: 'scale',
      width: 500,
      height: 500,
    }
  }
})

To fetch a remote image using Cloudinary, you can set cloud.storageType to fetch.

See Fetch Remote example for more details.

buildVideoUrl(publicId, options)

  • publicId
    • Type: String
    • Required
    • Path to the video stored in Cloudinary, or the full Cloudinary video URL.
  • options
    • Type: CldOptions
    • Consists two fields: cloud and transformations. See the options parameter for more details.

Generate delivery URL for a video with publicId and given options, including options.cloud extra configurations, and options.transformations - the transformations to apply.

import { buildVideoUrl } from 'cloudinary-build-url'

const url = buildVideoUrl('dog', {
  cloud: {
    cloudName: 'demo',
  },
  transformations: {
    resize: {
      type: 'scale',
      width: 500,
    }
  }
})

The options parameter

This is the Object containing configurations and transformations you wish to apply to an asset when generating the delivery URL. It includes two fields:

options.cloud

Type: CloudConfig

The extra configuration to apply specifically on the target asset, besides the global configurations given by the call setConfig(). See Options for the full list of accepted properties.

{
  cloud: {
    cloudName: 'your-cloud-name'
    secure: false,
    resourceType: 'image',
    storageType: 'upload'
  }
}

options.transformations

Type: TransformerOption

The transformations to apply to the asset on delivery, such as format optimization, resizing, adding border, etc...

{
  transformations: {
    //Resize the image
    resize: {
      width: 500,
      height: 500,
      type: 'scale'
    },
    border: {
      width: 1,
      color: 'red'
    }
  }
}

See Transformations section for more details on the accepted transformation fields.