richeditor-android
richeditor-android copied to clipboard
How To Add Images And Videos from Gallery
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 Can you please tell me the data string works or not for uploading images?
@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 Actually I am sending base64 string in this method. mEditor.insertImage(yourdatastring,alt,width,height) But selected image is not loaded in Editor view.
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 Then How we can prepare links after selecting an image from the device?
@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 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...
Contact me on either Fb - Jayant Navrange or Instagram idevelop.around.I'll try to help you there 🙂
@vikas-jain-plutus
@jayantur13 Requested on Instagram.
@jayantur13 Can you please guide me over here? If you have no issues.
@jayantur13 Can you please guide me over here? If you have no issues.
Sure, I'm there to discuss.
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.
Hi !
I found a solution with encode base64 : https://github.com/wasabeef/richeditor-android/issues/289
Bye and good luck for the future.
Clerclem