diff --git a/ios/Classes/core/PHAsset+PM_COMMON.h b/ios/Classes/core/PHAsset+PM_COMMON.h index 0a4273e2..9a91c41d 100644 --- a/ios/Classes/core/PHAsset+PM_COMMON.h +++ b/ios/Classes/core/PHAsset+PM_COMMON.h @@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSString*)mimeType; - (BOOL)isAdjust; - (PHAssetResource *)getAdjustResource; +- (PHAssetResource *)getUntouchedResource; - (void)requestAdjustedData:(void (^)(NSData *_Nullable result))block; - (PHAssetResource *)getLivePhotosResource; diff --git a/ios/Classes/core/PHAsset+PM_COMMON.m b/ios/Classes/core/PHAsset+PM_COMMON.m index aafee1e1..f0946893 100644 --- a/ios/Classes/core/PHAsset+PM_COMMON.m +++ b/ios/Classes/core/PHAsset+PM_COMMON.m @@ -68,7 +68,7 @@ - (NSString *)originalFilenameWithSubtype:(int)subtype { return [self getLivePhotosResource].originalFilename; } } - PHAssetResource *resource = [self getAdjustResource]; + PHAssetResource *resource = [self getUntouchedResource]; if (resource) { return resource.originalFilename; } @@ -120,6 +120,31 @@ - (BOOL)videoIsAdjust:(NSArray *)resources { return NO; } +- (PHAssetResource *)getUntouchedResource { + NSArray *resources = [PHAssetResource assetResourcesForAsset:self]; + if (resources.count == 0) { + return nil; + } + + if (resources.count == 1) { + return resources[0]; + } + + for (PHAssetResource *res in resources) { + if (self.mediaType == PHAssetMediaTypeImage + && res.type == PHAssetResourceTypePhoto) { + return res; + } + + if (self.mediaType == PHAssetMediaTypeVideo + && res.type == PHAssetResourceTypeVideo) { + return res; + } + } + + return nil; +} + - (PHAssetResource *)getAdjustResource { NSArray *resources = [PHAssetResource assetResourcesForAsset:self]; if (resources.count == 0) {