Reputation: 783
is there an easy way to dell htmldocument (inside a JTextPane) to not load images from the web? i cant think of anything smarter then to simply remove the tags or similar. and cant seem to find any "build in" functionality for it.
Upvotes: 0
Views: 148
Reputation: 783
this is the best i came up with:
String removeImageTags(String content)
{
Pattern imageRegexp = Pattern.compile("<img.*?src=['\"]{1}([^\"']*)['\"]{1}.*?>");
Matcher m = imageRegexp.matcher(content);
if (m.find())
{
content = m.replaceFirst(m.group(1));
}
else
{
return content;
}
return removeImageTags(content);
}
Upvotes: 1