I am trying to use the navigator.camera object to capture an image and push it into an img tag. I am doing what the demo says in the phonegap docs like this:
if(navigator.camera) {
navigator.camera.getPicture(function(imageData){
var $image = document.getElementById('imageForTask');
image.src = "data:image/jpeg;base64," + imageData;
console.log(imageData);
}, null, {sourceType:1, quality: 50});
} else {
alert("Camera not supported on this device.");
}
When I do this though, I get a broken link in the imageForTask . This is what the source says: data:image/jpeg;base64,content://media/external/images/media/325. Does anyone know why this wouldn’t work? I have been wrestling with this for awhile. Thanks!
-Geoff
The default destinationType has been changed from DATA_URL to FILE_URI. If you add an option:
to the options you pass to get picture you will be able to set it as base64 encoded data.
http://docs.phonegap.com/en/1.6.1/cordova_camera_camera.md.html#cameraOptions_options