Skip to content

Commit

Permalink
Display a normal link if we can't display an image.
Browse files Browse the repository at this point in the history
When the value of an annotation is an IRI that seems to point to an
image, and we are set to display thumbnails, check if we were able to
sucessfully load the remote image; if not, then fallback to display the
link, as if the "Display thumbnails for image URLs" option was disabled.
  • Loading branch information
gouttegd committed Jan 15, 2025
1 parent a0ef75a commit 608b684
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,11 @@ private List<Paragraph> renderExternalIRI(Page page, IRI iri) {
try {
if (isImageAddress(iri) && isDisplayThumbnails()) {
IconBox iconBox = getImageBox(iri);
page.add(iconBox);
if (iconBox != null) {
page.add(iconBox);
} else {
paragraphs.add(page.addParagraph(iriString, new HTTPLink(iri.toURI())));
}
}
else {
paragraphs.add(page.addParagraph(iriString, new HTTPLink(iri.toURI())));
Expand Down Expand Up @@ -469,7 +473,9 @@ public void setThumbnailRendering(InlineThumbnailRendering thumbnailRendering) {
*/
private IconBox getImageBox(IRI iri) throws MalformedURLException, IllegalArgumentException {
ImageIcon imageIcon = new ImageIcon(iri.toURI().toURL());
imageIcon.getImageLoadStatus();
if ( imageIcon.getImageLoadStatus() != MediaTracker.COMPLETE ) {
return null;
}
IconBox iconBox = new IconBox(imageIcon, new HTTPLink(iri.toURI()));
iconBox.setMaxHeight(50);
return iconBox;
Expand Down

0 comments on commit 608b684

Please sign in to comment.