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

How to set the image width to 100% by default #86

Closed
scandalYang opened this issue Jul 9, 2021 · 3 comments
Closed

How to set the image width to 100% by default #86

scandalYang opened this issue Jul 9, 2021 · 3 comments
Labels
question Further information is requested

Comments

@scandalYang
Copy link

45/5000
The default width of pictures and videos is very wide. You can set the width to 100% after clicking. How to make the default width of them be 100%

@scandalYang scandalYang added the question Further information is requested label Jul 9, 2021
@tneotia
Copy link
Owner

tneotia commented Jul 9, 2021

Hi there, once I get home I will post an example for you here. :)

@tneotia
Copy link
Owner

tneotia commented Jul 13, 2021

Sorry for the delay, something like this should work:

Widget editor = HtmlEditor(
    controller: controller,
    toolbarOptions: ToolbarOptions(
      mediaUploadInterceptor: (PlatformFile file, InsertFileType type) async {
         if (type == InsertFileType.image) {
              String base64Data = base64.encode(file.bytes!);
              String base64Image =
              """<img src="data:image/${file.extension};base64,$base64Data" data-filename="${file.name}" width="your_width_here"/>""";
              controller.insertHtml(base64Image);
            }
      },
    ),
  );

You can apply a hardcoded width or from MediaQuery to suit your needs inside the HTML string there.

@tneotia
Copy link
Owner

tneotia commented Jul 15, 2021

Hope the above answer helped you, closing for now. Let me know if you have further questions.

@tneotia tneotia closed this as completed Jul 15, 2021
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

2 participants