Skip to content

Instantly share code, notes, and snippets.

@matzew
Created March 17, 2014 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/9602314 to your computer and use it in GitHub Desktop.
Save matzew/9602314 to your computer and use it in GitHub Desktop.
Cordova Photo Picker
  1. cordova plugin add org.apache.cordova.camera

  2. simple HTML

	<img style="display:none;width:400px;height:400px;" id="bildcken" src="" />
	<button onclick="takePhoto();">TAKE IT</button>

And the required JS:

	function takePhoto() {
	      navigator.camera.getPicture(
		          function(imageData) {
			  
				  var bild = document.getElementById('bildcken');
	 			  bild.style.display = 'block';
				  bild.src = "data:image/jpeg;base64," + imageData;
 
		        },
				function() {
				 alert("YU NO WORK???")
				 }, { quality: 50, destinationType: Camera.DestinationType.DATA_URL,
	                        sourceType: 1,      // 0:Photo Library, 1=Camera, 2=Saved Album
	                        encodingType: 0});
	    }
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment