Skip to content

Commit df150d2

Browse files
authored
patch imagepickerios video widths (#3)
* patch ImagePickerIOS to also give a width and height if it detects movies * clean up
1 parent efef5b7 commit df150d2

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Libraries/CameraRoll/RCTImagePickerManager.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#import <React/RCTRootView.h>
1818
#import <React/RCTUtils.h>
1919

20+
@import Photos;
21+
2022
@interface RCTImagePickerController : UIImagePickerController
2123

2224
@property (nonatomic, assign) BOOL unmirrorFrontFacingCamera;
@@ -143,7 +145,15 @@ - (void)imagePickerController:(UIImagePickerController *)picker
143145
if (image) {
144146
height = @(image.size.height);
145147
width = @(image.size.width);
148+
} else if (isMovie) {
149+
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithALAssetURLs:@[[info valueForKey:UIImagePickerControllerReferenceURL]] options:nil];
150+
if (assets.count > 0) {
151+
PHAsset *videoAsset = assets.firstObject;
152+
height = @(videoAsset.pixelHeight);
153+
width = @(videoAsset.pixelWidth);
154+
}
146155
}
156+
147157
if (imageURL) {
148158
[self _dismissPicker:picker args:@[imageURL.absoluteString, RCTNullIfNil(height), RCTNullIfNil(width)]];
149159
return;

0 commit comments

Comments
 (0)