Hello i am trying to develop android app to load images from images gallery. Here is code snipet. i am not able display image. Can some one point me where it went wrong?
Here ia ImageURI i am receiving afetr selecting any file from image gallery:content://media/external/images/media/17. I blindly hard coded this value for my image src. But I am not seeing any. Any inputs here?
Also, the ImageURI is not binding for my text box too. Alert is display URI properly.
Its seeme pretty straight forward using normal phonegap app. But w/ ionic framework i am not abel to.
you’re not showing where you store the uri upon success. Show the full code. Here’s my example from doing something similar http://plnkr.co/edit/H8FcGn?p=preview
above is my full code. I haven’t added anything other than that. I am calling UploadPicture() and storing imageURI in $scope.ImageURI and then I am binding to tag.
I THINK the problem is your lack of “dot notation”.
You are doing : $scope.ImageURI = 'Select Image'; That is binding ImageURI to a primitive - a simple string. With that, you will not get 2 way binding. Later when you change $scope.ImageURI to an actual path, the view does not update because it is a copy of “Select Image” not a reference to an object that can be updated.
Calendee, Thanks for you time in replying for my post. I did the same way exacty you mentioned, but I am still not able to bind ng-src. Here is my code. Let me know if I still miss something here.
I even tried binding ng-src={{data.ImageURI}} but still no luck. I am not sure what I am doing wrong here. I tried for 2 hours but nothing work. Appreciate your help on this.
content://media/external/images/media/17 isn’t a path.
You need to use window.resolveLocalFileSystemURI
$cordovaCamera.getPicture(options).then(function(imageURI) {
//A hack that you should include to catch bug on Android 4.4 (bug < Cordova 3.5):
if (imageURI.substring(0,21)=="content://com.android") {
var photo_split=imageURI.split("%3A");
imageURI="content://media/external/images/media/"+photo_split[1];
}
window.resolveLocalFileSystemURI(imageURI, function(fileEntry) {
//If this doesn't work
$scope.image = fileEntry.nativeURL;
//Try this
//var image = document.getElementById('myImage');
//image.src = fileEntry.nativeURL;
});
});
And just to make sure AngularJS isn’t blacklisting lets whitelist:
Please help me. I am new to ionic, Around 20 days I am searching for correct solution. pls share your html code and js code and also pls explain whether I want to install any plugin for this???
Anyone figure out a solution to this yet? I’ve implemented the photo_split workaround and white listed but selecting images from gallery still fails regardless of if I try to copy to a different location or display image based on it’s url.
Someone PLEASE help me,thanks in advance.
I resolved this issue .
just by doing below change
add below line in config $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|mailto|content|file|assets-library):|data:image/);
IMP: camera plugin FILE_URI doesn’t work in live load