Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How can I pick images from gallery directly? #97

Closed
victor-bao opened this issue Aug 2, 2021 · 3 comments
Closed

[QUESTION] How can I pick images from gallery directly? #97

victor-bao opened this issue Aug 2, 2021 · 3 comments
Labels
question Further information is requested

Comments

@victor-bao
Copy link

victor-bao commented Aug 2, 2021

Hi,
In my app, my users do not have chance to input url for images and I am wondering whether I can remove this window.

IMG_9498

My questions:

Is it possible to remove this window without modifying original code of the library? One way I thought was I should define two custom bottoms for image upload and video upload, but after that, how can I pass the images link or base64 data to controller and insert into editor because I can not use mediaUploadInterceptor?

thanks for help!

@victor-bao victor-bao added the question Further information is requested label Aug 2, 2021
@tneotia
Copy link
Owner

tneotia commented Aug 2, 2021

Yes you can do this:

            HtmlEditor(
                controller: controller,
                htmlToolbarOptions: HtmlToolbarOptions(
                  onButtonPressed: (ButtonType type, bool? status,
                      Function()? updateStatus) {
                    if (type == ButtonType.picture) {
                       showDialog(); //show your custom dialog here or directly open image picker
                       return false; //this tells the plugin we handled image in a custom way
                    }
                    return true; //this tells the plugin to handle everything else as normal
                  },
                ),
              ),

and in the dialog complete method

//upload base64 data here
controller.insertNetworkImage(url); //to insert via URL
controller.insertHtml("<img src='data:image/$extension;base64,$base64Data'/>"); //to insert base64

Hope it helps! If it doesn't work or you have any other questions let me know.

@tneotia tneotia closed this as completed Aug 13, 2021
@weebsproject
Copy link

String base64Data = base64.encode(file.bytes!);
String base64Image =
"""<audio src="data:audio/${file.extension};base64,$base64Data" data-filename="${file.name}" style="width: 100% />""";
controller.insertHtml(base64Image);

above code to resize image into 100% in base 64 .

is there any way to resize image on insertNetworkImage using custom html tags?

@tneotia
Copy link
Owner

tneotia commented Mar 19, 2022

Yes, just make <img> src attribute into the network URL of the image, and apply your desired width.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants