Skip to content

Commit d79c0a2

Browse files
committed
merge fixes
signed-off-by: niendo1 <peter@niendo.de> Signed-off-by: niendo1 <peter@niendo.de>
1 parent ef32e60 commit d79c0a2

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

richeditor/src/main/java/jp/wasabeef/richeditor/RichEditor.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -507,26 +507,27 @@ public void insertImage(String url, String alt, String width, String height, Boo
507507
exec("javascript:RE.insertImage('" + url + "', '" + alt + "','" + width + "', '" + height + "', '" + relative.toString() + "');");
508508
}
509509

510-
public void insertImageAsBase64(Uri imageURI, String alt, String width, String height, Boolean relative) {
511-
InputStream inputStream = null;
512-
try {
513-
inputStream = getContext().getContentResolver().openInputStream(imageURI);
514-
} catch (FileNotFoundException e) {
515-
e.printStackTrace();
516-
}
510+
public void insertImageAsBase64(Uri imageURI, String alt, String width, String height) {
511+
InputStream inputStream = null;
512+
try {
513+
inputStream = getContext().getContentResolver().openInputStream(imageURI);
514+
} catch (FileNotFoundException e) {
515+
e.printStackTrace();
516+
}
517517

518-
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
519-
try {
520-
inputStream.close();
521-
} catch (IOException e) {
522-
e.printStackTrace();
523-
}
524-
String type = getContext().getContentResolver().getType(imageURI).toLowerCase();
525-
String tag = "data:" + type + ";charset=utf-8;base64,";
526-
exec("javascript:RE.prepareInsert();");
527-
exec("javascript:RE.insertImage('" + tag + Utils.toBase64(bitmap, type) + "','" + alt + "','" + width + "', '" + height + "', '" + relative.toString() + "');");
528-
//exec("javascript:RE.insertImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==','alt');");
518+
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
519+
try {
520+
inputStream.close();
521+
} catch (IOException e) {
522+
e.printStackTrace();
529523
}
524+
//String format = getContext().getContentResolver().getType(imageURI).toLowerCase();
525+
String format = "png";
526+
String tag = "data:image/" + format + ";charset=utf-8;base64,";
527+
exec("javascript:RE.prepareInsert();");
528+
exec("javascript:RE.insertImage('" + tag + Utils.toBase64(bitmap, format) + "','" + alt + "','" + width + "', '" + height + "');");
529+
//exec("javascript:RE.insertImage('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==','alt');");
530+
}
530531

531532
/**
532533
* {@link RichEditor#insertVideo(String, String, String, String)} will show the original size of the video.

0 commit comments

Comments
 (0)