Skip to content

Commit

Permalink
Merge branch 'devel' into feature/cordova-plugin-update-camera
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Oct 15, 2021
2 parents 9a1d1a5 + 6987552 commit b1f0163
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
9 changes: 8 additions & 1 deletion examples/simple-photo/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ if (Meteor.isClient) {
width: 800,
height: 600
};
if (Meteor.isCordova) {
cameraOptions.destinationType = 'URI'
}

MeteorCamera.getPicture(cameraOptions, function (error, data) {
Session.set("photo", data);
if (Meteor.isCordova) {
Session.set("photo", WebAppLocalServer.localFileSystemUrl(data))
} else {
Session.set("photo", data);
}
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-photo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"jquery": "^3.6.0",
"meteor-node-stubs": "^1.0.3"
"meteor-node-stubs": "^1.1.0"
}
}
4 changes: 4 additions & 0 deletions packages/mdg:camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v1.7.0, 2021-10-15

* Add option for Cordova to select `destinationType` on Cordova to allow to switch to `FILE_URI` instead of the default `DATA_URL`. Note, that you will need access to the device file system in order to display the images.

## v1.6.0, 2021-09-02

* Updated versions from and less version, fix issue #123
Expand Down
3 changes: 2 additions & 1 deletion packages/mdg:camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Prompt the user to take a photo with their device and get the picture as a Data
- `width` An integer that specifies the minimum width of the returned photo.
- `height` An integer that specifies the minimum height of the returned photo.
- `quality` A number from 0 to 100 specifying the desired quality of JPEG encoding.
- `destinationType` For Cordova ONLY. Pass in `URI` to get back file uri instead of base64 image (the default). If you want to display the photo taken see [Local Files section](https://guide.meteor.com/cordova.html#accessing-local-files) in the Guide and use the `WebAppLocalServer.localFileSystemUrl()` function for convert the `file://` url.

You can use other options from [Cordova Camera Options](https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-camera/#module_Camera) as they get passed on, with the exception of `destinationType`.
You can use other options from [Cordova Camera Options](https://cordova.apache.org/docs/en/10.x/reference/cordova-plugin-camera/#module_Camera) on Cordova as they get passed on.

#### callback(error, data)

Expand Down
11 changes: 9 additions & 2 deletions packages/mdg:camera/photo-cordova.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
MeteorCamera.getPicture = function (options, callback) {
var URIMode = false
// if options are not passed
if (! callback) {
callback = options;
options = {};
} else if (options.destinationType === 'URI') {
URIMode = true
}

var success = function (data) {
callback(null, "data:image/jpeg;base64," + data);
if (URIMode) {
callback(null, data);
} else {
callback(null, "data:image/jpeg;base64," + data);
}
};

var failure = function (error) {
Expand All @@ -18,7 +25,7 @@ MeteorCamera.getPicture = function (options, callback) {
quality: options.quality || 49,
targetWidth: options.width || 640,
targetHeight: options.height || 480,
destinationType: Camera.DestinationType.DATA_URL
destinationType: URIMode ? Camera.DestinationType.FILE_URI : Camera.DestinationType.DATA_URL
})
);
};

0 comments on commit b1f0163

Please sign in to comment.