How to use the ionic plugin cordova-plugin-image-picker

        When using ionic's default photo picker, you can only single-select one photo, which is not very convenient, so the cordova-plugin-image-picker plugin is generally used.
        The first step is to add the plugin to the project, enter the project directory, and run
ionic plugin add cordova-plugin-image-picker

        The second step is to add a method in the corresponding controller. You can search for the meaning of the specific parameters.
$scope.image_list = [];
$scope.pictureLibrary=function(){
  var options = {
    maximumImagesCount: 10,
    width: 800,
    height: 800,
    quality: 80
  };
  $cordovaImagePicker.getPictures(options)
    .then(function (results) {
      $scope.image_list = results;
    }, function(error) {
      // error getting photos
      alert("error"+error);
    });

};

        The third step is to call on the page and preview the image
<button class="button button-assertive" ng-click="pictureLibrary()">
    photo album
</button>

<ion-list>
    <div class="row row-wrap">
        <div class="col col-20" ng-repeat="image in image_list">
            <img src={{image}} width="100%"/>
        </div>
    </div>
</ion-list>

        The first three steps can be used normally, but you will find that its buttons and prompts are all in English. If you don’t think it will affect you, you can end the third step. If you want to change to Chinese, you need to The following steps.
        The fourth step, find the directory platforms/android/res with several folders for internationalization
values-de
values-en
values-fr
values-hu
values
values-ko

        Seeing this, I think you may already know it, just copy a folder and rename it values-zh, the corresponding file multiimagechooser_strings_ko.xml in it is also renamed multiimagechooser_strings_zh.xml, and replace the content
<?xml version='1.0' encoding='UTF-8'?>
<resources>
    <string name="multi_app_name">image selector</string>
    <string name="free_version_label">Free version - remaining images: %d</string>
    <string name="error_database">Error opening album.</string>
    <string name="requesting_thumbnails">请稍后。。。</string>
    <string name="discard">取消</string>
    <string name="done">确定</string>
</resources>

        The fifth step is to modify the source code file platforms/android/src/com/synconset/MultiImageChooserActivity.java, starting from line 175 (the number of lines in different versions may be inconsistent), search for it
progress = new ProgressDialog(this);
progress.setTitle("Image processing");
progress.setMessage("Please wait...");

        In this way, the modification is basically completed. I feel that the steps I wrote are still relatively detailed, but it may not be so easy to understand if I don’t understand ionic development and the directory structure. The use itself is not too complicated. It is easy to complete as long as you are careful. Don't post blogs, I hope you all correct me.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326902966&siteId=291194637