Media

Allow users to share device media with your custom JavaScript code.

Select or take a picture​

Ask the user to open the camera to take a picture or select a picture from the gallery.

import { pickImage } from '@myjsblock/sdk'

const image = await pickImage();

console.log(image); // Prints base64 result of image

Arguments​

NameTypeRequiredDefaultNotes

maxHeight

number

-

maxWidth

number

-

quality

number

-

Value between 1 and 100, controls compression level

showCameraOption

boolean

-

showGalleryOption

boolean

-

Errors​

Here is a list of errors that can be thrown when calling this function in addition to generic errors:

Error CodeDescription

OPERATION_CANCELLED

The user cancelled the operation.

UNKNOWN_ERROR

An error occurred while opening the camera or gallery, for example, the user may have denied permission

Last updated