CameraCaptureController

Camera Capture Controller

Provides enhanced mobile camera capture functionality. Works in conjunction with HTML5 file input capture attribute.

Note: Most camera functionality is handled by HTML5 capture="environment" attribute. This controller provides UI enhancements and fallback behavior.

Targets:

  • cameraInput: File input with camera capture
  • cameraButton: Optional button to trigger camera
  • preview: Preview area for captured images

Actions:

  • triggerCamera: Open device camera
  • handleCapture: Handle image capture

Methods

connect()

Initialize controller

detectMobileDevice()

Detect if user is on mobile device Updates UI to show mobile-specific instructions

formatFileSize(bytes) → {string}

Format file size

Parameters:
NameTypeDescription
bytesnumber

File size in bytes

Returns:

Formatted size

Type: 
string

handleCapture(event)

Handle image capture Called when user selects/captures an image

Parameters:
NameTypeDescription
eventEvent

File input change event

showImagePreview(file)

Show image preview (optional enhancement)

Parameters:
NameTypeDescription
fileFile

Image file to preview

triggerCamera(event)

Trigger camera input Useful if you have a custom camera button instead of using the file input directly

Parameters:
NameTypeDescription
eventEvent

Button click event

(static) supportsCameraCapture() → {boolean}

Check if browser supports camera capture

Returns:

True if capture is supported

Type: 
boolean