Here is how a typical ImageKit URL with custom CNAME will look like:
- "images.example.com" is the custom CNAME.
- "/" is the default URL pattern
- "tr:w-100" is transformation string
- "default-image.jpg" is the file path
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.
Mapping custom CNAME to whole URL pattern
There is an option to map a custom CNAME to the whole URL pattern so that you don't have to write URL pattern prefix in the images URL.
For example, here "product-images" is an URL pattern and by mapping the custom CNAME "product-images.example.com" to this particular URL pattern, we don't have to use "ik.imagekit.io/bjw6qtr5x/product-images"
https://ik.imagekit.io/bjw6qtr5x/product-images is equivalent to "product-images.example.com"
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.
The pattern is ‘img’, the transformation string is ‘tr:w-150,h-150’ and the effective URL is ‘files/sample-file.jpg’.