Return an Optional for the album image.
[Sone.git] / src / main / java / net / pterodactylus / sone / template / AlbumAccessor.java
index 13b4d65..51cd974 100644 (file)
@@ -43,12 +43,14 @@ public class AlbumAccessor extends ReflectionAccessor {
                if ("backlinks".equals(member)) {
                        List<Link> backlinks = new ArrayList<Link>();
                        Album currentAlbum = album;
-                       while (!currentAlbum.equals(album.getSone().getRootAlbum())) {
+                       while (!currentAlbum.isRoot()) {
                                backlinks.add(0, new Link("imageBrowser.html?album=" + currentAlbum.getId(), currentAlbum.getTitle()));
                                currentAlbum = currentAlbum.getParent();
                        }
                        backlinks.add(0, new Link("imageBrowser.html?sone=" + album.getSone().getId(), SoneAccessor.getNiceName(album.getSone())));
                        return backlinks;
+               } else if ("albumImage".equals(member)) {
+                       return album.getAlbumImage().orNull();
                }
                return super.get(templateContext, object, member);
        }