mirror of https://github.com/M66B/FairEmail.git
Make images link to themselves
This commit is contained in:
parent
2a04594b0d
commit
37981b0ac3
|
@ -701,7 +701,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
|
||||||
@Override
|
@Override
|
||||||
public Drawable getDrawable(String source) {
|
public Drawable getDrawable(String source) {
|
||||||
float scale = context.getResources().getDisplayMetrics().density;
|
float scale = context.getResources().getDisplayMetrics().density;
|
||||||
int px = (int) (24 * scale + 0.5f);
|
int px = (int) (48 * scale + 0.5f);
|
||||||
|
|
||||||
if (source != null && source.startsWith("cid")) {
|
if (source != null && source.startsWith("cid")) {
|
||||||
String[] cids = source.split(":");
|
String[] cids = source.split(":");
|
||||||
|
|
|
@ -36,8 +36,21 @@ public class HtmlHelper {
|
||||||
|
|
||||||
public static String sanitize(String html) {
|
public static String sanitize(String html) {
|
||||||
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed().addProtocols("img", "src", "cid")));
|
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed().addProtocols("img", "src", "cid")));
|
||||||
|
|
||||||
for (Element tr : document.select("tr"))
|
for (Element tr : document.select("tr"))
|
||||||
tr.after("<br>");
|
tr.after("<br>");
|
||||||
|
|
||||||
|
for (Element img : document.select("img"))
|
||||||
|
if (img.hasParent() && !"a".equals(img.parent().tagName())) {
|
||||||
|
String src = img.attr("src");
|
||||||
|
if (src.startsWith("http://") || src.startsWith("https://")) {
|
||||||
|
Element a = document.createElement("a");
|
||||||
|
a.attr("href", src);
|
||||||
|
img.replaceWith(a);
|
||||||
|
a.appendChild(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NodeTraversor.traverse(new NodeVisitor() {
|
NodeTraversor.traverse(new NodeVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void head(Node node, int depth) {
|
public void head(Node node, int depth) {
|
||||||
|
|
Loading…
Reference in New Issue