diff --git a/app/src/main/java/eu/faircode/email/HtmlHelper.java b/app/src/main/java/eu/faircode/email/HtmlHelper.java index 4928769bdd..382e12bc72 100644 --- a/app/src/main/java/eu/faircode/email/HtmlHelper.java +++ b/app/src/main/java/eu/faircode/email/HtmlHelper.java @@ -49,7 +49,6 @@ import android.text.style.TypefaceSpan; import android.text.style.URLSpan; import android.text.style.UnderlineSpan; import android.util.Base64; -import android.util.DisplayMetrics; import android.util.Patterns; import androidx.annotation.NonNull; @@ -993,7 +992,6 @@ public class HtmlHelper { // Images // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img - DisplayMetrics dm = context.getResources().getDisplayMetrics(); for (Element img : document.select("img")) { String alt = img.attr("alt"); String src = img.attr("src"); @@ -1043,23 +1041,25 @@ public class HtmlHelper { int width = 0; int height = 0; + // Relative sizes (%) = use image size + String awidth = img.attr("width").replace(" ", ""); for (int i = 0; i < awidth.length(); i++) if (Character.isDigit(awidth.charAt(i))) width = width * 10 + (byte) awidth.charAt(i) - (byte) '0'; - else + else { + width = 0; break; - if (awidth.endsWith("%")) - width = Math.round(dm.widthPixels / dm.density * width / 100); + } String aheight = img.attr("height").replace(" ", ""); for (int i = 0; i < aheight.length(); i++) if (Character.isDigit(aheight.charAt(i))) height = height * 10 + (byte) aheight.charAt(i) - (byte) '0'; - else + else { + height = 0; break; - if (aheight.endsWith("%")) - height = Math.round(dm.heightPixels / dm.density * height / 100); + } if (width != 0 || height != 0) { ImageHelper.AnnotatedSource a = new ImageHelper.AnnotatedSource(