File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
SDWebImagePhotosPlugin/Classes Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 37
37
*/
38
38
@property (nonatomic , strong , nullable ) PHImageRequestOptions *imageRequestOptions;
39
39
40
+ /* *
41
+ Whether we request only `PHAssetMediaTypeImage` asset and ignore other types (video/audio/unknown).
42
+ When we found other type, an error `SDWebImagePhotosErrorNotImageAsset` will be reported.
43
+ Defaults to YES. If you prefer to load other type like video asset's poster image, set this value to NO.
44
+ */
45
+ @property (nonatomic , assign ) BOOL requestImageAssetOnly;
46
+
40
47
@end
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ - (instancetype)init {
77
77
requestOptions.version = PHImageRequestOptionsVersionCurrent;
78
78
self.imageRequestOptions = requestOptions;
79
79
self.operationsTable = [NSHashTable weakObjectsHashTable ];
80
+ self.requestImageAssetOnly = YES ;
80
81
self.fetchQueue = dispatch_queue_create (" SDWebImagePhotosLoader" , DISPATCH_QUEUE_SERIAL);
81
82
#if SD_UIKIT
82
83
[[NSNotificationCenter defaultCenter ] addObserver: self selector: @selector (didReceiveMemoryWarning: ) name: UIApplicationDidReceiveMemoryWarningNotification object: nil ];
@@ -155,8 +156,8 @@ - (BOOL)canRequestImageForURL:(NSURL *)url {
155
156
PHFetchResult<PHAsset *> *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers: @[localIdentifier] options: fetchOptions];
156
157
asset = fetchResult.firstObject ;
157
158
}
158
- // Only support image
159
- if (!asset || asset.mediaType != PHAssetMediaTypeImage) {
159
+ // Check whether we should request only image asset
160
+ if (!asset || (self. requestImageAssetOnly && asset.mediaType != PHAssetMediaTypeImage) ) {
160
161
// Call error
161
162
NSError *error = [NSError errorWithDomain: SDWebImagePhotosErrorDomain code: SDWebImagePhotosErrorNotImageAsset userInfo: nil ];
162
163
if (completedBlock) {
You can’t perform that action at this time.
0 commit comments