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 Source.network 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

AVAssetImageDataProvider

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

LocalFileImageDataProvider

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.

Base64ImageDataProvider

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

RawImageDataProvider

Represents an image data provider for a raw data object.

Default Implementations

content​URL

var contentURL: URL?  

convert​ToSource()

func convertToSource() -> Source  

Requirements

cache​Key

var cacheKey: String  

The key used in cache.

data(handler:​)

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.

Parameters

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.

content​URL

var contentURL: URL?  

The content URL represents this provider, if exists.