htorbov commented on issue #538: Best way to show it on a browser?
URL: 
https://github.com/apache/cordova-plugin-camera/issues/538#issuecomment-565207116
 
 
   Hi @breautek , thank you for your fast reply!
   
   Actually, I'm using the Camera plugin from a while, and it works perfectly 
on my Vue app (hybrid Web/Native app).
   
   **Calling Photo('capture') or Photo('select'):**
   ```javascript
   Photo: function (type) {
     const onSuccess = (response) => {
       // Here I get base64 with 'data:image/jpeg;base64,' + response
     }
   
     const onFail = (response) => {
       // Here I show an error dialog with `response`
     }
   
     const setOptions = (response) => {
       return {
         quality: 100,
         destinationType: window.Camera.DestinationType.FILE_URI,
         sourceType: response,
         encodingType: window.Camera.EncodingType.JPEG,
         mediaType: window.Camera.MediaType.PICTURE,
         allowEdit: true,
         correctOrientation: true
       }
     }
   
     window.navigator.camera.getPicture(onSuccess, onFail, setOptions(type === 
'capture' ? window.Camera.PictureSourceType.CAMERA : 
window.Camera.PictureSourceType.SAVEDPHOTOALBUM))
   }
   ```
   
   **To be honest, I do it this way, but it's a REALLY ugly hack made by me 
lol:**
   ```javascript
   Browser: function (type) {
     if (window.cordova.platformId === 'browser') {
       setTimeout(function () {
         document.getElementsByClassName('new-camera-div')[0].innerHTML = ''
   
         
document.getElementsByClassName('new-camera-div')[0].appendChild(document.getElementsByClassName('cordova-camera-'
 + type)[0])
       }, 500)
     }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to