I'm having this issue with FILE_URI similar to the one raised in another post:
--> Cordova 2.8.1: camera.getPicture with photolibarary source on ios
I've tried using a simple code similar to the example provided in the Cordova docs.
HTML:
<head>
<link rel="stylesheet" type="text/css" href="application.css">
<script src="http://localhost/cordova.js"></script>
<script src="/components/steroids-js/steroids.js"></script>
<script src="application.js"></script>
</head>
<body>
<div>
<br>
<button type="button" onclick="takePhoto()">Take photo</button>
<br>
<hr>
<p>Image should appear below:</p>
<img id="image" width="100%" height="100%" src="">
<hr>
<p>Image URI should appear below:</p>
<p id="URI"></p>
</div>
</body>
</html>
JS:
function onCameraSuccess(imageURI) {
document.getElementById('image').src = imageURI;
document.getElementById('URI').innerHTML = imageURI;
}
function onCameraFail(message) {
alert('Failed because: ' + message);
}
function takePhoto() {
navigator.camera.getPicture(onCameraSuccess, onCameraFail, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: 1, // 0:Photo Library, 1:Camera, 2:Photo Album
encodingType: 0, // 0:JPG 1:PNG
allowEdit: true,
correctOrientation: true,
saveToPhotoAlbum: true,
});
}
I'm using the Cordova 3.1 API from AppGyver on iOS7. I tried using all the combinations of navigator.camera vs Camera, FILE_URI vs NATIVE_URI, and JPG vs PNG. None of these combinations worked. However I still get the right URI path (file:///var/mobile/Applications/…/tmp/cdvphoto024.jpg) but the image won't show when given this path as a source. It works when using DATA_URL on both CAMERA and PHOTOLIBRARY but this is of no use to me since I need to be able to store the path in LocalStorage and move the image file to a permanent location. Any idea how to solve this issue? Or maybe a workaround where I could use the saveToPhotoAlbum option, but then I don't know how to retrieve the path of that newly captured image without going through the getPicture manual selection again. Any idea? Thx