chooseImage

Requires:
BaseKit≥2.0.1@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { chooseImage } from '@ray-js/ray';

// Promise usage
try {
  const res = await chooseImage({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
chooseImage(params: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 5.2.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.2.0

Description

Select images from the local album or take photos with the camera. You can use chooseMedia instead.
Permissions: [scope.camera, scope.writePhotosAlbum]
Related API: [chooseMedia]

Parameters

PropertyTypeRequiredDefaultDescriptionBaseKit SinceMinimum SDK versions
countnumberNo9Maximum number of images to select. Note: On Android 13 and above, the system image picker is used and this field has no effect-—
imageTypestringNo-Filter image types; pass 'gif' to show only GIFs, pass 'image' to show non-GIF static images; if omitted or empty, no filtering by defaultv3.32.13
iOSThingSmartBaseKitBizBundle
≥ 7.5.0
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 7.5.0
sizeTypestring[]No-Image size type; pass 'original' for the original image, 'compressed' for a compressed image-—
sourceTypestring[]No-Source for selecting images ['album', 'camera']-—
disableDismissAnimationAfterSelectbooleanNo-Whether to disable the animation when closing the interface after canceling image selectionv3.11.3
iOSThingSmartBaseKitBizBundle
≥ 5.14.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.14.0
complete() => voidNo-Completion callback (executed on both success and failure)-—
success(params: Object) => voidNo-Callback on successful API call-—
fail(params: Object) => voidNo-Failure callback-—
success callback parameters
PropertyTypeDescriptionBaseKit SinceMinimum SDK versions
tempFilePathsstring[]List of local temporary image file paths (local paths)v3.2.6—
[]List of selected image file objects, including the local temporary file path path and file size size (in bytes)v3.2.6—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Examples

import { chooseImage } from '@ray-js/ray'

// Select images from the album or take photos (invokes the system picker; manual selection required)
chooseImage({
  count: 1,
  sizeType: ["compressed"],
  sourceType: ["album", "camera"],
  success: data => console.log("Selected images:", data.tempFilePaths),
  fail: error => console.error(error),
});