ImageKit URL construction (without custom CNAME)

Understanding different components of an image URL.

Manu avatar
Written by Manu
Updated over a week ago

Here is how a typical ImageKit URL will look like:

  • "ik.imagekit.io" is default base URL.

  • "demo" is imagekit_ID

  • "/" is the default URL pattern

  • "tr:w-100" is transformation string

  • "default-image.jpg" is the file path

Imagekit ID

ImageKit ID is the unique identifier for your account that you select at the time of registration. You can find your ImageKit ID in the top-right corner of your ImageKit dashboard. This is the first thing that appears in your URL after the hostname.

URL pattern

A URL pattern is any unique, customisable identifier that will appear in your image URL. A URL pattern can contain only alphabets, numbers and hyphens. Read more about URL pattern here.

Transformation

This part of the URL is used to specify the transformations and optimizations that you want to perform on an image. The transformation string always begins with the prefix 'tr:' For example – 'tr:w-100'

If you do not want any transformation on your image, except for the default ones, then you can omit this in the URL.

You can read about available transformations here.

Rest of the path

The image is fetched using this URL. This URL will be searched on all the image sources that are available for the URL pattern specified in the URL.

Examples URLs

Here are a few examples to understand how URLs are parsed by ImageKit. In these examples, will use ‘demo’ as the ImageKit ID.

1. Default pattern without transformation

https://ik.imagekit.io/demo/default-image.jpg

The effective URL here is ‘default-image.jpg’.

2. Default pattern with transformation

https://ik.imagekit.io/demo/tr:w-100,h-100/default-image.jpg

The transformation string is ‘tr:w-100,h-100’ and the effective URL is ‘default-image.jpg’

3. ‘img’ pattern with transformation

https://ik.imagekit.io/demo/img/tr:w-150,h-150/files/sample-file.jpg

The pattern is ‘img’, the transformation string is ‘tr:w-150,h-150’ and the effective URL is ‘files/sample-file.jpg’.

Did this answer your question?