Make images link to themselves

pull/146/head
M66B 6 years ago
parent 2a04594b0d
commit 37981b0ac3

@ -701,7 +701,7 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
@Override
public Drawable getDrawable(String source) {
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")) {
String[] cids = source.split(":");

@ -36,8 +36,21 @@ public class HtmlHelper {
public static String sanitize(String html) {
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed().addProtocols("img", "src", "cid")));
for (Element tr : document.select("tr"))
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() {
@Override
public void head(Node node, int depth) {

Loading…
Cancel
Save