KingfisherOptionsInfoItem
public enum KingfisherOptionsInfoItem
Represents the available option items could be used in KingfisherOptionsInfo
.
-
Kingfisher will use the associated
ImageCache
object when handling related operations, including trying to retrieve the cached images and store the downloaded image to it.Declaration
Swift
case targetCache(ImageCache)
-
The
ImageCache
for storing and retrieving original images. IforiginalCache
is contained in the options, it will be preferred for storing and retrieving original images. If there is no.originalCache
in the options,.targetCache
will be used to store original images.When using KingfisherManager to download and store an image, if
cacheOriginalImage
is applied in the option, the original image will be stored to thisoriginalCache
. At the same time, if a requested final image (with processor applied) cannot be found intargetCache
, Kingfisher will try to search the original image to check whether it is already there. If found, it will be used and applied with the given processor. It is an optimization for not downloading the same image for multiple times.Declaration
Swift
case originalCache(ImageCache)
-
Kingfisher will use the associated
ImageDownloader
object to download the requested images.Declaration
Swift
case downloader(ImageDownloader)
-
Member for animation transition when using
UIImageView
. Kingfisher will use theImageTransition
of this enum to animate the image in if it is downloaded from web. The transition will not happen when the image is retrieved from either memory or disk cache by default. If you need to do the transition even when the image being retrieved from cache, set.forceRefresh
as well.Declaration
Swift
case transition(ImageTransition)
-
Associated
Float
value will be set as the priority of image download task. The value for it should be between 0.0~1.0. If this option not set, the default value (URLSessionTask.defaultPriority
) will be used.Declaration
Swift
case downloadPriority(Float)
-
If set, Kingfisher will ignore the cache and try to fire a download task for the resource.
Declaration
Swift
case forceRefresh
-
If set, Kingfisher will try to retrieve the image from memory cache first. If the image is not in memory cache, then it will ignore the disk cache but download the image again from network. This is useful when you want to display a changeable image behind the same url at the same app session, while avoiding download it for multiple times.
Declaration
Swift
case fromMemoryCacheOrRefresh
-
If set, setting the image to an image view will happen with transition even when retrieved from cache. See
.transition
option for more.Declaration
Swift
case forceTransition
-
If set, Kingfisher will only cache the value in memory but not in disk.
Declaration
Swift
case cacheMemoryOnly
-
If set, Kingfisher will wait for caching operation to be completed before calling the completion block.
Declaration
Swift
case waitForCache
-
If set, Kingfisher will only try to retrieve the image from cache, but not from network. If the image is not in cache, the image retrieving will fail with an error.
Declaration
Swift
case onlyFromCache
-
Decode the image in background thread before using. It will decode the downloaded image data and do a off-screen rendering to extract pixel information in background. This can speed up display, but will cost more time to prepare the image for using.
Declaration
Swift
case backgroundDecode
-
The associated value of this member will be used as the target queue of dispatch callbacks when retrieving images from cache. If not set, Kingfisher will use main queue for callbacks.
Declaration
Swift
case callbackDispatchQueue(DispatchQueue?)
-
The associated value will be used as the target queue of dispatch callbacks when retrieving images from cache. If not set, Kingfisher will use
.mainCurrentOrAsync
for callbacks.Note
This option does not affect the callbacks for UI related extension methods. You will always get the callbacks called from main queue.Declaration
Swift
case callbackQueue(CallbackQueue)
-
The associated value will be used as the scale factor when converting retrieved data to an image. Specify the image scale, instead of your screen scale. You may need to set the correct scale when you dealing with 2x or 3x retina images. Otherwise, Kingfisher will convert the data to image object at
scale
1.0.Declaration
Swift
case scaleFactor(CGFloat)
-
Whether all the animated image data should be preloaded. Default is
false
, which means only following frames will be loaded on need. Iftrue
, all the animated image data will be loaded and decoded into memory.This option is mainly used for back compatibility internally. You should not set it directly. Instead, you should choose the image view class to control the GIF data loading. There are two classes in Kingfisher support to display a GIF image.
AnimatedImageView
does not preload all data, it takes much less memory, but uses more CPU when display. While a normal image view (UIImageView
orNSImageView
) loads all data at once, which uses more memory but only decode image frames once.Declaration
Swift
case preloadAllAnimationData
-
The
ImageDownloadRequestModifier
contained will be used to change the request before it being sent. This is the last chance you can modify the image download request. You can modify the request for some customizing purpose, such as adding auth token to the header, do basic HTTP auth or something like url mapping. The original request will be sent without any modification by default.Declaration
Swift
case requestModifier(ImageDownloadRequestModifier)
-
The
ImageDownloadRedirectHandler
contained will be used to change the request before redirection. This is the posibility you can modify the image download request during redirect. You can modify the request for some customizing purpose, such as adding auth token to the header, do basic HTTP auth or something like url mapping. The original redirection request will be sent without any modification by default.Declaration
Swift
case redirectHandler(ImageDownloadRedirectHandler)
-
Processor for processing when the downloading finishes, a processor will convert the downloaded data to an image and/or apply some filter on it. If a cache is connected to the downloader (it happens when you are using KingfisherManager or any of the view extension methods), the converted image will also be sent to cache as well. If not set, the
DefaultImageProcessor.default
will be used.Declaration
Swift
case processor(ImageProcessor)
-
Supplies a
CacheSerializer
to convert some data to an image object for retrieving from disk cache or vice versa for storing to disk cache. If not set, theDefaultCacheSerializer.default
will be used.Declaration
Swift
case cacheSerializer(CacheSerializer)
-
An
ImageModifier
is for modifying an image as needed right before it is used. If the image was fetched directly from the downloader, the modifier will run directly after theImageProcessor
. If the image is being fetched from a cache, the modifier will run after theCacheSerializer
.Use
ImageModifier
when you need to set properties that do not persist when caching the image on a concrete type ofImage
, such as therenderingMode
or thealignmentInsets
ofUIImage
.Declaration
Swift
case imageModifier(ImageModifier)
-
Keep the existing image of image view while setting another image to it. By setting this option, the placeholder image parameter of image view extension method will be ignored and the current image will be kept while loading or downloading the new image.
Declaration
Swift
case keepCurrentImageWhileLoading
-
If set, Kingfisher will only load the first frame from an animated image file as a single image. Loading an animated images may take too much memory. It will be useful when you want to display a static preview of the first frame from a animated image.
This option will be ignored if the target image is not animated image data.
Declaration
Swift
case onlyLoadFirstFrame
-
If set and an
ImageProcessor
is used, Kingfisher will try to cache both the final result and original image. Kingfisher will have a chance to use the original image when another processor is applied to the same resource, instead of downloading it again. You can use.originalCache
to specify a cache or the original images if necessary.The original image will be only cached to disk storage.
Declaration
Swift
case cacheOriginalImage
-
If set and a downloading error occurred Kingfisher will set provided image (or empty) in place of requested one. It’s useful when you don’t want to show placeholder during loading time but wants to use some default image when requests will be failed.
Declaration
Swift
case onFailureImage(Image?)
-
If set and used in
ImagePrefetcher
, the prefetching operation will load the images into memory storage aggressively. By default this is not contained in the options, that means if the requested image is already in disk cache, Kingfisher will not try to load it to memory.Declaration
Swift
case alsoPrefetchToMemory
-
If set, the disk storage loading will happen in the same calling queue. By default, disk storage file loading happens in its own queue with an asynchronous dispatch behavior. Although it provides better non-blocking disk loading performance, it also causes a flickering when you reload an image from disk, if the image view already has an image set.
Set this options will stop that flickering by keeping all loading in the same queue (typically the UI queue if you are using Kingfisher’s extension methods to set an image), with a tradeoff of loading performance.
Declaration
Swift
case loadDiskFileSynchronously
-
The expiration setting for memory cache. By default, the underlying
MemoryStorage.Backend
uses the expiration in its config for all items. If set, theMemoryStorage.Backend
will use this associated value to overwrite the config setting for this caching item.Declaration
Swift
case memoryCacheExpiration(StorageExpiration)
-
The expiration extending setting for memory cache. The item expiration time will be incremented by this value after access. By default, the underlying
MemoryStorage.Backend
uses the initial cache expiration as extending value: .cacheTime. To disable extending option at all add memoryCacheAccessExtendingExpiration(.none) to options.Declaration
Swift
case memoryCacheAccessExtendingExpiration(ExpirationExtending)
-
The expiration setting for memory cache. By default, the underlying
DiskStorage.Backend
uses the expiration in its config for all items. If set, theDiskStorage.Backend
will use this associated value to overwrite the config setting for this caching item.Declaration
Swift
case diskCacheExpiration(StorageExpiration)
-
Decides on which queue the image processing should happen. By default, Kingfisher uses a pre-defined serial queue to process images. Use this option to change this behavior. For example, specify a
.mainCurrentOrAsync
to let the image be processed in main queue to prevent a possible flickering (but with a possibility of blocking the UI, especially if the processor needs a lot of time to run).Declaration
Swift
case processingQueue(CallbackQueue)
-
Enable progressive image loading, Kingfisher will use the
ImageProgressive
ofDeclaration
Swift
case progressiveJPEG(ImageProgressive)