richeditor-android icon indicating copy to clipboard operation
richeditor-android copied to clipboard

How To Add Images And Videos from Gallery

Open faizanShoukat55 opened this issue 4 years ago • 14 comments

faizanShoukat55 avatar Sep 22 '20 15:09 faizanShoukat55

For Image - To add image from phone you can make a picker which returns data string from intent,then you can do mEditor.insertImage(yourdatastring,alt,width,height)

Image from url may work, it requires internet permission maybe

Tested on Oreo 8.0

jayantur13 avatar Oct 19 '20 08:10 jayantur13

@jayantur13 Can you please tell me the data string works or not for uploading images?

vikas-jain-plutus avatar Feb 25 '21 12:02 vikas-jain-plutus

@jayantur13 Can you please tell me the data string works or not for uploading images?

Its working, you can change width, height of image too.

jayantur13 avatar Feb 25 '21 12:02 jayantur13

@jayantur13 Actually I am sending base64 string in this method. mEditor.insertImage(yourdatastring,alt,width,height) But selected image is not loaded in Editor view.

vikas-jain-plutus avatar Feb 25 '21 18:02 vikas-jain-plutus

I think encoded string is not supported..Links like https://myimages/image.jpg (direct path) are only supported and shown in the example too.

jayantur13 avatar Feb 25 '21 18:02 jayantur13

@jayantur13 Then How we can prepare links after selecting an image from the device?

vikas-jain-plutus avatar Feb 25 '21 18:02 vikas-jain-plutus

@jayantur13 Then How we can prepare links after selecting an image from the device?

From the image's path file:///mnt/sdcard/myPicture.jpg or like from content://media/external/audio/media/710 Make a picker,pick an image you will get either file path or content path of image,you'll see the image in the editor

private void singleImgPicker(){
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        someActivityResultLauncher.launch(intent);

    }


    ActivityResultLauncher<Intent> someActivityResultLauncher = registerForActivityResult(
            new ActivityResultContracts.StartActivityForResult(),
            new ActivityResultCallback<ActivityResult>() {
                @Override
                public void onActivityResult(ActivityResult result) {
                    if(result.getResultCode() == Activity.RESULT_OK && result.getData() != null){
                        Intent data = result.getData();
                        imglnk = data.getDataString();
                    }
                }
            });

jayantur13 avatar Feb 25 '21 18:02 jayantur13

@jayantur13 I have used the same method as you mentioned above but the main issue is like, I need to send HTML of that image and the same image will be reflected on the web portal as well. So If I am using your way to collect data string of local image path, then it will not display on portal or web server. Please help me on this.... Thanks in Advance...

vikas-jain-plutus avatar Mar 04 '21 07:03 vikas-jain-plutus

Contact me on either Fb - Jayant Navrange or Instagram idevelop.around.I'll try to help you there 🙂

@vikas-jain-plutus

jayantur13 avatar Mar 04 '21 07:03 jayantur13

@jayantur13 Requested on Instagram.

vikas-jain-plutus avatar Mar 04 '21 12:03 vikas-jain-plutus

@jayantur13 Can you please guide me over here? If you have no issues.

vikas-jain-plutus avatar Mar 05 '21 08:03 vikas-jain-plutus

@jayantur13 Can you please guide me over here? If you have no issues.

Sure, I'm there to discuss.

jayantur13 avatar Mar 05 '21 09:03 jayantur13

Hello, I can't choose an image in my local storage, display the image in my RichEditor and stock the image in my database (I stock my html in my database) in same time. I work with android 11 API 30. My AndroidManifest.xml containt this lines : <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

If I use this line : instanceFragment.getRichEditor().insertImage("https://raw.githubusercontent.com/wasabeef/art/master/chip.jpg", "image", 300); The image is display in the RichEditor and I can stock in my database but I have don't choose my image in my local storage.

If I use this line : instanceFragment.getRichEditor().insertImage("File://" + destination.getPath(), "image", 300); The image isn't display in the RichEditor (the alt is display) but I can stock in my database and I have choose my image in my local storage.

If I use this line : instanceFragment.getRichEditor().insertImage(url, "image", 300); The image is display in the RichEditor and I have choose my image in my local storage but I can't stock in my database (because this is a temp url).

This is my code : RichEditor.txt

Can you help me please ? Thank in advance.

Clement-Cauet avatar Feb 24 '23 17:02 Clement-Cauet

Hi !

I found a solution with encode base64 : https://github.com/wasabeef/richeditor-android/issues/289

Bye and good luck for the future.

Clerclem

Clement-Cauet avatar Apr 25 '23 12:04 Clement-Cauet