Socket
Socket
Sign inDemoInstall

@jonz94/capacitor-image-picker

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jonz94/capacitor-image-picker

Capacitor plugin for multiple image selection


Version published
Weekly downloads
9
decreased by-43.75%
Maintainers
1
Install size
39.5 kB
Created
Weekly downloads
 

Changelog

Source

2.0.1 (2024-03-12)

Bug Fixes

  • ios: resolve xcode 15 issue (#14) (1a7829d), closes #12

Readme

Source


Image Picker

@jonz94/capacitor-image-picker

Capacitor plugin for multiple image selection.

Install

npm install @jonz94/capacitor-image-picker
npx cap sync

iOS

Native Dependencies Setup

This plugin uses a forked version of YPImagePicker under the hood.

In order to use this plugin, you need to manually modified ios/App/Podfile as following:

target 'App' do
  capacitor_pods
  # Add your Pods here
+  pod 'YPImagePicker', :git => 'https://github.com/jonz94/YPImagePicker.git', :tag => '5.2.2.0'
end

After modified ios/App/Podfile, make sure to run pod update command to sync up the iOS project.

Permissions

iOS requires the following usage description be added and filled out for your app in Info.plist:

  • NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)

Read about Configuring Info.plist in the iOS Guide for more information on setting iOS permissions in Xcode.

Android

Native Dependencies Setup

This plugin uses a forked version of TedImagePicker under the hood.

Setup JitPack Repository

Add following line to your android/build.gradle:

allprojects {
    repositories {
        google()
        mavenCentral()
+        maven { url "https://jitpack.io" }
    }
}
Enable Data Binding

Add following lines to your android/app/build.gradle:

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        // ...
    }
    buildTypes {
        // ...
    }
+    dataBinding {
+        enabled true
+    }
}
Sync Project

After modified android/build.gradle and android/app/build.gradle, make sure to run Sync Project with Gradle Files in Android Studio.

Permissions

This plugin requires the following permissions be added to your AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />

The storage permissions are for reading photo files.

Read about Setting Permissions in the Android Guide for more information on setting Android permissions.

Configuration

No configuration required for this plugin.

Usage

import { ImagePicker } from '@jonz94/capacitor-image-picker';

const pickSingleImage = async () => {
  const { images } = await ImagePicker.present();

  // console.log(images[0]);

  return images[0];
}

const pickMultipleImages = async () => {
  const { images } = await ImagePicker.present({ limit: 10 });

  // console.log(images);

  return images;
}

const pickMultipleImagesWithCustomText = async () => {
  const { images } = await ImagePicker.present({
    limit: 10,
    surpassLimitMessage: 'You cannot select more than %d images.',
    titleText: 'Pick a image',
    albumsTitleText: 'Chose an album',
    libraryTitleText: 'Click here to change library',
    cancelText: 'Go Back',
    doneText: 'OK',
  });

  // console.log(images);

  return images;
}

API

present(...)

present(options?: PresentOptions | undefined) => Promise<Images>
ParamType
optionsPresentOptions

Returns: Promise<Images>


Interfaces

Images
PropTypeDescriptionSince
imagesImage[]Array of all the picked images.1.0.0
Image
PropTypeDescriptionSince
pathstringThe file path of the image.1.0.0
webPathstringwebPath returns a path that can be used to set the src attribute of an image for efficient loading and rendering.1.0.0
mimeTypestringThe mime type of the image.1.0.0
PresentOptions
PropTypeDescriptionDefaultSince
limitnumberMaximum number of images the user will be able to choose. Note: If this is set to 1, upon selection of a single image.11.0.0
surpassLimitMessagestringThe message when user select more than maximum number of pictures. This message will not occur when limit is 1. Note: The message MUST INCLUDE ONE AND ONLY ONE %d as a placeholder for showing the value of limit."You can only select %d images."1.0.0
titleTextstringAndroid only: The title of the image picker."Select Image"1.0.0
albumAllTextstringAndroid only: name of the all photos album."All"1.2.0
libraryTitleTextstringiOS only: The title of the library."Library"1.0.0
albumsTitleTextstringiOS only: The title of the albums."Albums"1.0.0
cancelTextstringiOS only: The text to display on the cancel button. Note: on Android, the cancel button is shown as icon-only back button with no text."Cancel"1.0.0
doneTextstringThe text to display on the done button."Done"1.0.0

Changelog

See CHANGELOG.md.

License

See LICENSE.

Credits

Keywords

FAQs

Last updated on 12 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc