If the image that is requested using ImageKit does not exist, then a 404 error is shown. However, there might be a need where instead of giving a broken image to the user, you want a default image to be delivered. ImageKit provides a way to do this without having to handle this at application level.

This option di specifies the path of the image that will be delivered if the original image is not available. The default image should be available in the ImageKit Media Library directly and not on one of your image origins. The default image path cannot contain slashes (“/”). All the transformations that are applied to the original image in the URL will be applied on the default image as well before delivering it.

For example: If this is your default image

Default Image: 

https://ik.imagekit.io/demo/medium_cafe_B1iTdD0C.jpg

Then use the following URL to get the default image in case an error occurs while fetching the original image. 

https://ik.imagekit.io/demo/tr:di-medium_cafe_B1iTdD0C.jpg/non_existent_image.jpg

Did this answer your question?