Kingfisher Documentation

Protocol Image​Data​Provider

public protocol ImageDataProvider  

Represents a data provider to provide image data to Kingfisher when setting with Source.provider source. Compared to member, it gives a chance to load some image data in your own way, as long as you can provide the data representation for the image.

%197 ImageDataProvider ImageDataProvider Base64ImageDataProvider Base64ImageDataProvider Base64ImageDataProvider->ImageDataProvider AVAssetImageDataProvider AVAssetImageDataProvider AVAssetImageDataProvider->ImageDataProvider RawImageDataProvider RawImageDataProvider RawImageDataProvider->ImageDataProvider LocalFileImageDataProvider LocalFileImageDataProvider LocalFileImageDataProvider->ImageDataProvider

Types Conforming to Image​Data​Provider


A data provider to provide thumbnail data from a given AVKit asset.


Represents an image data provider for loading from a local file URL on disk. Uses this type for adding a disk image to Kingfisher. Compared to loading it directly, you can get benefit of using Kingfisher's extension methods, as well as applying ImageProcessors and storing the image to ImageCache of Kingfisher.


Represents an image data provider for loading image from a given Base64 encoded string.


Represents an image data provider for a raw data object.

Default Implementations


var contentURL: URL?  


func convertToSource() -> Source  



var cacheKey: String  

The key used in cache.


func data(handler: @escaping (Result<Data, Error>) -> Void) 

Provides the data which represents image. Kingfisher uses the data you pass in the handler to process images and caches it for later use.


handler @escaping (Result<Data, Error>) -> Void

The handler you should call when you prepared your data. If the data is loaded successfully, call the handler with a .success with the data associated. Otherwise, call it with a .failure and pass the error.


var contentURL: URL?  

The content URL represents this provider, if exists.