/

Media, Camera & Video Uploads

Video fields and live in-browser camera capture, with change_type('video') and change_type('camera').

Video uploads

change_type($field, 'video', '', $extra) is its own field type, not 'file' pointed at video extensions - no GD-based image processing applies (resize/crop/watermark/thumbs are all image-only), and there's no configurable preview mode to pick between: a video field always shows a native <video controls> player. The list cell shows a small muted poster-frame-only version; clicking it opens the full player, full-size, in the same modal chrome the image field's own preview uses.

$xcrud->change_type('simple_video', 'video', '', ['not_rename' => true]);
OptionTypeDefaultDescription
not_renameboolfalseKeep the uploaded file's original name (still sanitized against path traversal), same meaning as on 'file'.

Uploaded videos are validated against XcrudConfig::$uploadAllowedVideoExt (default ['mp4', 'webm', 'ogg']) - the same not-just-trusting-the-extension posture 'image' gets from getimagesize(), though video has no equivalent lightweight signature check available without an ffmpeg dependency, so the extension whitelist plus the project's usual can't-execute-anything-served-from-here boundary is what carries the weight here instead.

Camera capture

change_type($field, 'camera', '', $extra) captures a photo directly from a device's camera via the browser's getUserMedia() API - a live preview plus a Capture button next to the usual dropzone, with no file picker needed. Useful on mobile/tablet where snapping a photo directly is faster than navigating a file browser.

$xcrud->change_type('camera_photo', 'camera', '', ['width' => 800, 'height' => 800]);

Everything past capture - storage, resize/crop/watermark options, the list thumbnail, click-to-preview - is identical to a plain 'image' field; 'camera' shares the same image-like processing options (width/height/crop/manual_crop/ratio/watermark/watermark_position/thumbs) documented on the File & Image Uploads page - only the capture side differs.

On a browser or context with no camera access at all (an old browser, a denied permission, a non-HTTPS/non-localhost origin - camera access needs a secure context), the field falls back to the normal file picker rather than a dead end.

Shared upload configuration

XcrudConfig::$uploadAllowedVideoExt (default ['mp4', 'webm', 'ogg']) governs which video extensions are accepted by both 'video' and, where relevant, any video captured through 'camera'. $uploadDir and $uploadMaxSize apply here the same way they do for file/image fields - see the XcrudConfig Reference.