Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
patch ImagePickerIOS to also give a width and height if it
detects movies
  • Loading branch information
victorias committed Jul 10, 2019
commit 8208ee5050bf1cfa8231617669c2019bfabc0695
12 changes: 12 additions & 0 deletions Libraries/CameraRoll/RCTImagePickerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#import <React/RCTRootView.h>
#import <React/RCTUtils.h>

@import Photos;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont think we need this since we already #import <Photos/Photos.h> earlier?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHFetchResult and PHAsset depends on this and if we don't have it the compiler can't find the definitions :\ idk tbh but a quick google said we had to do this


@interface RCTImagePickerController : UIImagePickerController

@property (nonatomic, assign) BOOL unmirrorFrontFacingCamera;
Expand Down Expand Up @@ -146,6 +148,16 @@ - (void)imagePickerController:(UIImagePickerController *)picker
height = @(image.size.height);
width = @(image.size.width);
}

if (isMovie) {
PHFetchResult<PHAsset *> *assets = [PHAsset fetchAssetsWithALAssetURLs:@[[info valueForKey:UIImagePickerControllerReferenceURL]] options:nil];
if (assets.count > 0) {
PHAsset *videoAsset = assets.firstObject;
width = @(videoAsset.pixelWidth);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

micro-nit: height before width as that order is matched above in 148 for consistency.

height = @(videoAsset.pixelHeight);
}
}

if (imageURL) {
[self _dismissPicker:picker args:@[imageURL.absoluteString, RCTNullIfNil(height), RCTNullIfNil(width)]];
return;
Expand Down