Notice: Include
assets/js/plugins/webcam.js
before using the webcam plugin.
HTML Setup:
<!-- The button that will open the webcam -->
<button type="button" class="webcam">Webcam</button>
<!-- The webcam container -->
<div id="webcam-container" style="display: none;">
<div class="camera"></div>
<button type="button" class="snap">Take picture</button>
<button type="button" class="close-webcam">Close webcam</button>
</div>
JavaScript:
// Filepicker plugin
var FP = $('#filepicker').filePicker({...});
// Webcam plugin call
FilepickerWebcam(FP, {
container: $('#webcam-container'),
openButton: $('.webcam'),
// more options ...
});
Requires Bootstrap.
HTML Setup:
<div class="modal fade" id="webcam-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Webcam</h4>
</div>
<div class="modal-body">
<div class="camera"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default close-webcam" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-info snap">Take picture</button>
</div>
</div>
</div>
</div>
JavaScript:
// Filepicker plugin
var FP = $('#filepicker').filePicker({...});
// Webcam plugin call
FilepickerWebcam(FP, {
container: $('#webcam-modal'),
openButton: $('.webcam'),
modal: true, // Optional, because it auto detects Bootstrap modal support.
// more options ...
});
The swf flash file used when the HTML5 webcam is not available (IE & Safari).
assets/js/plugins/webcam.swf
The size of the embedded flash file.
[568, 423]
The jQuery object for the webcam container or Bootstrap modal.
n/a
$('#webcam-container')
/ $('#webcam-modal')
Whether to enable Bootstrap modal. Optional, because it auto detects Bootstrap modal support.
false
/ true
when using Bootstrap modalThe jQuery object for the element where the webcam preview will be rendered.
container.find('.camera')
$('.camera-preview')
The jQuery object for the button that will open the webcam.
n/a
$('.webcam')
The jQuery object for the button that will take a picture and upload it.
container.find('.snap')
$('.snap-btn')
The jQuery object for the button that will close the webcam.
container.find('.close-webcam')
$('.close-webcam-btn')