mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 09:47:13 +00:00
Link images to anchors without hyperlink
This commit is contained in:
parent
8028304485
commit
692b1e5ce2
1 changed files with 12 additions and 9 deletions
|
@ -83,15 +83,18 @@ public class HtmlHelper {
|
|||
for (Element img : document.select("img")) {
|
||||
img.prependElement("br");
|
||||
|
||||
boolean linked = false;
|
||||
for (Element parent : img.parents())
|
||||
if ("a".equals(parent.tagName())) {
|
||||
linked = true;
|
||||
break;
|
||||
}
|
||||
if (!linked) {
|
||||
String src = img.attr("src");
|
||||
if (src.startsWith("http://") || src.startsWith("https://")) {
|
||||
String src = img.attr("src");
|
||||
if (src.startsWith("http://") || src.startsWith("https://")) {
|
||||
boolean linked = false;
|
||||
for (Element parent : img.parents())
|
||||
if ("a".equals(parent.tagName())) {
|
||||
if (TextUtils.isEmpty(parent.attr("href")))
|
||||
parent.attr("href", img.attr("src"));
|
||||
linked = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!linked) {
|
||||
Element a = document.createElement("a");
|
||||
a.attr("href", src);
|
||||
a.appendChild(img.clone());
|
||||
|
|
Loading…
Reference in a new issue