SDImagePhotosLoader

@interface SDImagePhotosLoader : NSObject

The imgae loader to load image asset from Photos library. You need to register the loader into manager firstly. Use @import SDWebImagePhotosPlugin to import full framework instead of each header.

Note

To control single image request options, use the context option in SDWebImagePhotosDefine.h.

Note

Use NSURL+SDWebImagePhotosPlugin.h category to create Photos URL instead of string. Use PHImageRequestOptions+SDWebImagePhotosPlugin.h category to provide extra info for request options.

Note

And it’s also strongly recommeded to totally disable memory cache if you want to query batch of Photos images frequently. You can do this by using SDWebImageFromLoaderOnly options during image request. And you can use SDWebImageContextStoreCacheType with SDImageCacheTypeNone to disable cache storing. This is because Photos framework manage the image cache by their own process outside your application process and can reduce memory usage.
  • The global shared instance for Photos loader.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull, class)
        SDImagePhotosLoader *sharedLoader;

    Swift

    class var shared: SDImagePhotosLoader { get }
  • The default fetchOptions used for PHAsset fetch with the localIdentifier. Defaults to nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) PHFetchOptions *fetchOptions;

    Swift

    var fetchOptions: PHFetchOptions? { get set }
  • The default imageRequestOptions used for image asset request. Defatuls value are these: networkAccessAllowed = YES; resizeMode = PHImageRequestOptionsResizeModeFast; deliveryMode = PHImageRequestOptionsDeliveryModeOpportunistic; version = PHImageRequestOptionsVersionCurrent;

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable)
        PHImageRequestOptions *imageRequestOptions;

    Swift

    var imageRequestOptions: PHImageRequestOptions? { get set }
  • Whether we request only PHAssetMediaTypeImage asset and ignore other types (video/audio/unknown). When we found other type, an error SDWebImagePhotosErrorNotImageAsset will be reported. Defaults to YES. If you prefer to load other type like video asset’s poster image, set this value to NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL requestImageAssetOnly;

    Swift

    var requestImageAssetOnly: Bool { get set }