SDImageCacheOptions

enum SDImageCacheOptions {}

Image Cache Options

  • By default, we do not query image data when the image is already cached in memory. This mask can force to query image data at the same time. However, this query is asynchronously unless you specify SDImageCacheQueryMemoryDataSync

    Declaration

    Objective-C

    SDImageCacheQueryMemoryData = 1 << 0

    Swift

    static var queryMemoryData: SDImageCacheOptions { get }
  • By default, when you only specify SDImageCacheQueryMemoryData, we query the memory image data asynchronously. Combined this mask as well to query the memory image data synchronously.

    Declaration

    Objective-C

    SDImageCacheQueryMemoryDataSync = 1 << 1

    Swift

    static var queryMemoryDataSync: SDImageCacheOptions { get }
    • By default, when the memory cache miss, we query the disk cache asynchronously. This mask can force to query disk cache (when memory cache miss) synchronously.

    Note

    These 3 query options can be combined together. For the full list about these masks combination, see wiki page.

    Declaration

    Objective-C

    SDImageCacheQueryDiskDataSync = 1 << 2

    Swift

    static var queryDiskDataSync: SDImageCacheOptions { get }
  • By default, images are decoded respecting their original size. On iOS, this flag will scale down the images to a size compatible with the constrained memory of devices.

    Declaration

    Objective-C

    SDImageCacheScaleDownLargeImages = 1 << 3

    Swift

    static var scaleDownLargeImages: SDImageCacheOptions { get }
  • By default, we will decode the image in the background during cache query and download from the network. This can help to improve performance because when rendering image on the screen, it need to be firstly decoded. But this happen on the main queue by Core Animation. However, this process may increase the memory usage as well. If you are experiencing a issue due to excessive memory consumption, This flag can prevent decode the image.

    Declaration

    Objective-C

    SDImageCacheAvoidDecodeImage = 1 << 4

    Swift

    static var avoidDecodeImage: SDImageCacheOptions { get }
  • By default, we decode the animated image. This flag can force decode the first frame only and produce the static image.

    Declaration

    Objective-C

    SDImageCacheDecodeFirstFrameOnly = 1 << 5

    Swift

    static var decodeFirstFrameOnly: SDImageCacheOptions { get }
  • By default, for SDAnimatedImage, we decode the animated image frame during rendering to reduce memory usage. This flag actually trigger preloadAllAnimatedImageFrames = YES after image load from disk cache

    Declaration

    Objective-C

    SDImageCachePreloadAllFrames = 1 << 6

    Swift

    static var preloadAllFrames: SDImageCacheOptions { get }
  • By default, when you use SDWebImageContextAnimatedImageClass context option (like using SDAnimatedImageView which designed to use SDAnimatedImage), we may still use UIImage when the memory cache hit, or image decoder is not available, to behave as a fallback solution. Using this option, can ensure we always produce image with your provided class. If failed, an error with code SDWebImageErrorBadImageData will be used. Note this options is not compatible with SDImageCacheDecodeFirstFrameOnly, which always produce a UIImage/NSImage.

    Declaration

    Objective-C

    SDImageCacheMatchAnimatedImageClass = 1 << 7

    Swift

    static var matchAnimatedImageClass: SDImageCacheOptions { get }