-
-
Notifications
You must be signed in to change notification settings - Fork 72
selected.getImage is not a function #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Pierre im facing a similar issue, well, not exactly, but on the latest version of the plugin v6, the selection is really an ImageAsset from nativescript and it is not exactly working as the code you indicate. |
I tested this using the latest (6.0.1) version of the image picker plugin. For Android, getting the image path is very easy. Assuming selection.forEach(function(selected) {
console.log(selected.android.toString());
}); For iOS, it is a bit more tricky as the native PHAsset object does not have a property containing the path: selection.forEach(function(selected) {
const ios = selected.ios;
if (ios && ios.mediaType === PHAssetMediaType.Image) {
const opt = PHImageRequestOptions.new();
opt.version = PHImageRequestOptionsVersion.Current;
PHImageManager.defaultManager().requestImageDataForAssetOptionsResultHandler(
ios, opt, (imageData: NSData, dataUTI: string, orientation: UIImageOrientation, info: NSDictionary<any, any>) => {
console.log(info.objectForKey("PHImageFileURLKey").toString());
});
}
}); |
Great info @lini thanks for sharing. |
@lini thank you for sharing your solution. Can you provide whole component code? As it says it cannot find NSData, UIImageOrientation, NSDictionary . I try to declare them but it didn't help. I haven't worked with native iOS code before. Thank you in advance. |
You need to add the |
thanks @lini |
+1 |
Please provide good documentation for last two versions. |
Sorry, to start the question here again, but how can I get the path to a Video?
I have the Video Player plugin installed and want to play the selected video in the app as a preview and later upload it to firebase. But I can't get this thing working. Any ideas / solutions? |
@ppulwey this works for me :
|
@pierremacedo find my complete solution here ...
|
How do we copy the image to app's directory to be able to actually make some use of that path? |
This no longer works on iOS 13. |
Working solution const ios: PHAsset = selected.ios;
if (ios && ios.mediaType === PHAssetMediaType.Image) {
filePath = await new Promise((resolve, reject) => {
ios.requestContentEditingInputWithOptionsCompletionHandler(
null,
(input, info) => {
resolve(input.fullSizeImageURL.toString().replace("file://", ""));
}
);
});
} |
@uzarsalan I'm using your example and it works occasionally for me, but quite often (especially with older photos) I get this error when selecting an image:
I logged the info & input params inside the function and I see this: info:
input: Does anyone know what this issue is? I'm guessing its something to do with iCloud maybe? as in, photos backing up to iCloud, then no longer being "on device". I'm new to this so not exactly sure. |
I'm making an app where some data are stored in a SQL database. But in order to store images and videos I need to get the file uri first. I tried everything I could but nothing worked.
This is how my JS file looks like:
I can select images without a problem but then I get this error "selected.getImage is not a function".
The text was updated successfully, but these errors were encountered: