imageLoader

abstract fun imageLoader(context: Context): ImageLoader

Returns a new Coil ImageLoader.


open fun imageLoader(context: Context, interceptors: List<Interceptor>): ImageLoader

Returns a new Coil ImageLoader with the given interceptors prepended to the component registry, ahead of all decoders and Coil's built-in EngineInterceptor.

The default implementation ignores interceptors and delegates to imageLoader. This means that when a custom StreamCoilImageLoaderFactory is used alongside ChatTheme's asyncImageHeadersProvider, the async headers will not be injected — the custom factory's loader is returned as-is.

Custom class implementations that want to support interceptor injection should override this method, for example by forwarding interceptors to StreamImageLoaderFactory:

override fun imageLoader(context: Context, interceptors: List<Interceptor>): ImageLoader =
StreamImageLoaderFactory(interceptors = interceptors, builder = myCustomBuilder)
.newImageLoader(context)

Integrators using a custom StreamCoilImageLoaderFactory who also need auth headers on image requests should either override this method or inject the headers directly inside their factory's imageLoader implementation (e.g. via a custom OkHttp client).

Parameters

context

The Context to build the ImageLoader with.

interceptors

Coil Interceptors to prepend to the component registry.