From 122b1db2f95439de687d781ddfce0fbd1ca8bcbf Mon Sep 17 00:00:00 2001 From: xick <> Date: Sun, 17 Sep 2023 18:08:56 +0200 Subject: [PATCH 1/3] [IOS] Add method to retrieve untouched resource (IN TESTING) Add method to retrieve original photo/video instead of altered one. getTitleAsync now returns original filename instead of 'FullsizeRender'. --- ios/Classes/core/PHAsset+PM_COMMON.h | 1 + ios/Classes/core/PHAsset+PM_COMMON.m | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) 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) { From 54583f23d0372d944b0fac7f12790f2f383f3bbe Mon Sep 17 00:00:00 2001 From: xick <> Date: Mon, 2 Oct 2023 19:59:28 +0200 Subject: [PATCH 2/3] update Changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6b7d4cb..5b8fb38f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ that can be found in the LICENSE file. --> # CHANGELOG +## 2.7.3 + +### Fixes + +- [iOS] Add PHAsset extension method `getUntouchedResource` to retrieve original media instead of one with adjustments / filters. +- [iOS] Fix: When retrieving an asset title, now returns original file name instead of `FullSizeRender.*` if this has adjustments. (#976) + ## 2.7.2 ### Fixes From d00df38aedf10f4e88619c83868984ea1bc0957c Mon Sep 17 00:00:00 2001 From: xick <> Date: Mon, 2 Oct 2023 21:06:10 +0200 Subject: [PATCH 3/3] Update Changelog --- CHANGELOG.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b8fb38f..3a6611ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,18 +4,13 @@ that can be found in the LICENSE file. --> # CHANGELOG -## 2.7.3 - -### Fixes - -- [iOS] Add PHAsset extension method `getUntouchedResource` to retrieve original media instead of one with adjustments / filters. -- [iOS] Fix: When retrieving an asset title, now returns original file name instead of `FullSizeRender.*` if this has adjustments. (#976) - ## 2.7.2 ### Fixes - Correct the key when fetching video info with MMR on Android. (#997) +- Retrieve original media instead of one with adjustments/filters for subtype files on iOS. (#976) +- Returns original file name instead of `FullSizeRender.*` if this has adjustments on iOS. (#976) ### Improvements